Created
March 2, 2016 04:08
-
-
Save joeyblake/8fab86e4c71654c19cdb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//row markup | |
$row = '<div class="row-fluid">%s</div>' | |
//$posts = whatever you are trying to put in a grid. | |
$span_divs = array(); | |
foreach ( $posts as $post ) { | |
//make a span box | |
$span_divs[] = sprintf( "<div class="span4">%s</div>" , $post); | |
} | |
//chunk the array of grid items into a number if items | |
foreach ( array_chunk($span_divs, 3) as $spans ) { | |
//pull the chunked array markup into the row markup and write it out | |
echo sprintf($row, implode('', $spans)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice