I want to loop through an array in Php and get 3 items at a time, for example if an array contains these numbers: [1,2,3,4,5,6,7,8,9,10,11]
then I want to be able to loop through it and get 3 at a time, but if the list does not break evenly into 3's then get whatever is left over.
So, in this example I would want (1,2,3), (4,5,6), (7,8,9), (10, 11). What is the easiest way to do this? This is what I have so far which is getting just one item at a time from the array:
for ($w = 0; $w < count($decoded_photos); $w++) {
$photo_reference = $decoded_photos[$w]["photo_reference"];
echo "photo reference " . $photo_reference;
}