php while loop in array code example
Example 1: while loop php
<?php
$a = 0;
while($a<=5){
echo $a."<br>";
$a++;
}
?>
Example 2: 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 />';
};