fork download
  1. <?php
  2. $array = [
  3. [1, 2],
  4. [3, 4],
  5. ];
  6.  
  7. foreach ($array as list($a, $b)) {
  8. // $a contains the first element of the nested array,
  9. // and $b contains the second element.
  10. echo "A: $a; B: $b\n";
  11. }
  12.  
  13. array_walk ($array, function ($value){
  14. list($a, $b) = $value;
  15. // $a contains the first element of the nested array,
  16. // and $b contains the second element.
  17. echo "A: $a; B: $b\n";
  18. });
  19.  
  20.  
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
A: 1; B: 2
A: 3; B: 4
A: 1; B: 2
A: 3; B: 4