我有一个带有混合索引的多维数组,即int和string值。
离。
['abc'][p][8][5]['amol']['jon']
在某些时候我知道需要在索引'abc'之后检查索引,无论是int还是string我该怎么做?
答案 0 :(得分:0)
next($array); //> Advancing
is_numeric(key($array)); //> Checking
答案 1 :(得分:-1)
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;
}
然后使用is_int()来检查int或string。