Answers for "php associative array get all keys for same value"

PHP
0

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);
}
?>
Posted by: Guest on April-01-2020

Code answers related to "php associative array get all keys for same value"

Browse Popular Code Answers by Language