This (array_search) may returns Boolean false on failure or integer(index of item) value:
Warning This function may return Boolean FALSE, but may also return a
non-Boolean value which evaluates to FALSE. Please read the section on
Booleans for more information. Use the === operator for testing the
return value of this function.
For example, this will return 0 but it's the first index (found):
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('blue', $array); // 0
if(getType($key) == 'boolean'){
// not found
}
Result is 0 here and if it's integer then it's the index of first item. So make sure that, whether the 0 is found index or not. You may set the third parameter to true to overcome this problem:
strict If the third parameter strict is set to TRUE then the
array_search() function will search for identical elements in the
haystack. This means it will also check the types of the needle in the
haystack, and objects must be the same instance.
So, using a strict comparison you may ensure the appropriate result:
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('blue', $array, true);
if($key !== false) {
// Found the index in $key
}
array_keys($student)return?foreach (array_keys($student) as $keys=>$values) echo $keys.$valuesthey display normally.var_dump(array_keys($student))and show us what it is[0]=>int(0)be the problem?