How to check if numbers are in correct sequence?
Posted
by
Nazariy
on Stack Overflow
See other posts from Stack Overflow
or by Nazariy
Published on 2012-07-10T21:05:07Z
Indexed on
2012/07/10
21:15 UTC
Read the original article
Hit count: 226
I have a two dimensional array that contain range of numbers that have to be validated using following rules, range should start from 0 and follow in arithmetic progression.
For example:
$array = array();
$array[] = array(0);//VALID
$array[] = array(0,1,2,3,4,5);//VALID
$array[] = array("0","1");//VALID
$array[] = array(0,1,3,4,5,6);//WRONG
$array[] = array(1,2,3,4,5);//WRONG
$array[] = array(0,0,1,2,3,4);//WRONG
what is most efficient way to do that in php?
UPDATE I forgot to add that numbers can be represented as string
© Stack Overflow or respective owner