how to find next index in php array?
I have multidimensional array with mixed index ie int and string values.
ex.
['abc'][p][8][5]['amol']['jon']
at Ce开发者_如何学运维rtain point i know the need to check index after index 'abc' , whether it is int or string how can i do that?
next($array); //> Advancing
is_numeric(key($array)); //> Checking
http://fi2.php.net/manual/en/function.key.php
function array_key_relative($array, $current_key, $offset = 1)
{ // create key map $keys = array_keys($array);
// find current key $current_key_index = array_search($current_key, $keys);
// return desired offset, if in array, or false if not
if(isset($keys[$current_key_index + $offset]))
{ return $keys[$current_key_index + $offset]; } return false;
}
then use is_int() to check int or string.
精彩评论