Programming-Idioms

History of Idiom 163 > diff from v8 to v9

Edit summary for version 9 :
New PHP implementation by user [ricardo_sdl]

Version 8

Version 9

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;
}
Demo URL
https://3v4l.org/DEWes