update page now
PHP 8.1.34 Released!

Voting

: max(seven, seven)?
(Example: nine)

The Note You're Voting On

Anonymous
3 years ago
This is the best example of using next in a loop

<?php
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

// this cycle echoes all associative array
// key where value equals "apple"
reset($array); // prepare array for cycle 
while ($fruit_name = current($array)) {
    if ($fruit_name == 'apple') {
        echo key($array), "\n";
    }
    next($array);
}
reset($array); 
?>

<< Back to user notes page

To Top