Selecting multiple array elements

I.e. instead of just looping through one array element at a time, but to loop through selected pairs instead (e.g. 3 elements, and then to do something to those 3).

there are many ways to do it.
one would be

$arr = array(1,2,3,4,5,6,7,8,9);
$new = array_chunk($arr,3);
foreach ($new as $chunk) {
  print_r($chunk);// 3 elements to do something with

Leave a Comment