$name = array( '孟子','孔子','孙子','老子' ); while($ele = each($name)){ $key = $ele['key']; // == $ele[0] $value = $ele['value']; // $ele[2] var_dump($key,$value); echo "<br>"; }
Although this is not commonly used, it is very useful for understanding the concept of array pointers (the best is to use foreach)
It can also be upgraded, using the List structure
The List structure uses an indexarray to initialize multiple arrays at the same time variables
$arr = array(0=>"some",1=>"many",2=>"much"); list($v1,$v2,$v3) = $arr; var_dump($v1,$v2,$v3);
while(list($key,$value) = each($name)){ // $key = $ele['key']; // == $ele[0] // $value = $ele['value']; // $ele[2] var_dump($key,$value); echo "<br>"; }
The above introduces list-each-while traversing arrays, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.