key
Fetch a key from an array
&reftitle.description;
mixedkey
arrayarray
key returns the index element of the current array
position.
&reftitle.parameters;
array
The array.
&reftitle.returnvalues;
Returns the index.
&reftitle.examples;
key example
'apple',
'fruit2' => 'orange',
'fruit3' => 'grape',
'fruit4' => 'apple',
'fruit5' => 'apple');
// this cycle echoes all associative array
// key where value equals "apple"
while ($fruit_name = current($array)) {
if ($fruit_name == 'apple') {
echo key($array).'
';
}
next($array);
}
?>
]]>
&example.outputs;
fruit4
fruit5
]]>
&reftitle.seealso;
current
next