Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Split WireArray/PageArray into chunks
<?php
// Thanks to netcarver > https://processwire.com/talk/topic/7803-implement-array-chunk/?p=75573
$items = $pages->find('#whatever'); // Find your stuff
$parts = 3; // How many items should there be in 1 chunk?
$chunked = array_chunk($items->getArray(), $parts);
foreach ($chunked as $chunk) {
foreach ($chunk as $item) {
// Do stuff like echo $item->title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment