Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php get array key


<?php
$array = array(
    'fruit1' => '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).'<br />';
    }
    next($array);
}
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #array #key
ADD COMMENT
Topic
Name
9+9 =