Last active
May 16, 2018 07:33
-
-
Save arjenblokzijl/909c08202899c641650e to your computer and use it in GitHub Desktop.
Split WireArray/PageArray into chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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