Logo

Programming-Idioms

History of Idiom 163 > diff from v8 to v9

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

Version 8

2018-08-03, 20:40:23

Version 9

2018-08-23, 19:26:24

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