I have an array as the following:
function example() {
/* some stuff here that pushes items with
dynamically created key strings into an array */
you can use key function of php to get the key name:
'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);
}
?>
like here : PHP:key - Manual