Posts tagged with “php”
Alternating background colors
I just wrote some pretty quick code for the age-old problem of alternating colors in a table. I don’t know how this could get any simpler. Sweet!
<? foreach($posts as $post){?>
<div class="<?=($c++%2==1)?'odd':NULL?>“>
<?=$post?>
</div><br />
<? }?><br />
<style>
.odd{background-color:red;}<br />
</style>Forcing a floated line-wrap in PHP
For every 4 floated elements, wrap to the next line:
<?=($b++%4==0)?'<br class="clr" />‘:NULL?>