Adding divs or any design patterns to a foreach loop every 4 or any times

foreach (array_chunk($posts, 4, true) as $pts) {
echo ‘</section>  or div or tr anything’;
foreach($pts as $t) {
echo $t->ID;
}
echo ‘</section>  or div or tr anything’;
}

Instead of doing mod split up on each foreach this method is clean and easy.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s