key Fetch a key from an associative array Description mixedkey array&array key returns the index element of the current array position. <function>key</function> 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); } ?> ]]>
See also current and next.