Last active
August 29, 2015 14:20
-
-
Save kohki-shikata/2f3954a4ae5cdf260b73 to your computer and use it in GitHub Desktop.
Grids by Foundation 5 need to add html class ".end" to the last element in ".row" element. This is how fix it by PHP.
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 | |
// make random color codes for background, to recognize betweens of each columns easily. | |
function rand_color() { | |
return sprintf("#%06x",rand(0,16777215)); | |
} | |
$color = rand_color(); | |
$cols = 9; // the number of columns want to generate | |
$hexes = array($color); | |
for( $ci = 1; $ci <= $cols - 1 ; $ci++) { | |
array_push($hexes,rand_color()); | |
} | |
// $i count-up version | |
$header = <<<EOM | |
\n | |
<h2 class="text-center">\$i count up</h1>\n | |
<div class="row"> | |
\n | |
EOM; | |
echo $header; | |
for( $i = 1; $i <= $cols ; $i++ ) { | |
?> | |
<section style="background-color: <?php echo $hexes[$i -1];?>" class="columns small-4<?php if($i == $cols){echo " end";}?>"> | |
<div class="inner"> | |
<h1>Header</h1> | |
<p>Templates systems are awesome</p> | |
</div> | |
</section> | |
<?php }; | |
echo "</div>"; | |
?> | |
<?php | |
// detect the last element of array | |
$header = <<<EOM | |
\n | |
<h2 class="text-center">Array version</h1>\n | |
<div class="row"> | |
\n | |
EOM; | |
echo $header; | |
foreach($hexes as $hex) { ?> | |
<section style="background-color: <?php echo $hex ?>" class="columns small-4<?php if($hex === end($hexes)){echo " end";} ?>"> | |
<div class="inner"> | |
<h1>The last of elements in the array</h1> | |
<p>Templates systems are awesome</p> | |
</div> | |
</section> | |
<?php } | |
echo "</div>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment