Answers for "while loop in php array"

PHP
2

php while loop array

$foodArray = ["Eggs", "Bacon", "HashBrowns", "Beans", "Bread"];

        foreach ($foodArray as $food)  {
            echo $food ."<br />";
        }
Posted by: Guest on March-07-2021
0

how to loop with while in php for array associative

$assocarray = array('a' => 1, 'b' => 2, 'c' => 3);
$keys = array_keys($assocarray);
rsort($keys);
while (!empty($keys)) {
    $key = array_pop($keys);
    echo $key . ' = ' . $assocarray[$key] . '<br />';
};
Posted by: Guest on December-05-2020

Browse Popular Code Answers by Language