Programming-Idioms

History of Idiom 163 > diff from v9 to v10

Edit summary for version 10 :
[PHP] Variable name list

Version 9

Version 10

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Code
foreach(array_chunk($l, 2) as $x) {
    echo $x[0], ' ', $x[1], PHP_EOL;
}
Code
foreach(array_chunk($list, 2) as $x) {
    echo $x[0], ' ', $x[1], PHP_EOL;
}
Demo URL
https://3v4l.org/DEWes
Demo URL
https://3v4l.org/DEWes