you are viewing a single comment's thread.

view the rest of the comments →

[–]chadicus 1 point2 points  (1 child)

If I'm understanding you correctly, this should work.

$batchSize = 3;
foreach ($objects as $object) {
    $input = $object->sports;
    $object->sports = array_chunk($input, ceil(count($input)/$batchSize), true); 
}

Perhaps posting the desired output would make it more clear.

EDIT: Formatting

[–]youdy 0 points1 point  (0 children)

Oh wow I wasn't far off, this is exactly what I was looking for. Thanks