Monday, March 30, 2009

PHP Alternating row colours using a shorthand if statements

$class = ($i % 2 ? 'low' : 'high');

<table>
<tr>
<td class="<?=$class?>">Row 1</td>
</tr>
<tr>
<td class="<?=$class?>">Row 2</td>
</tr>
<tr>
<td class="<?=$class?>">Row 3</td>
</tr>
</table>

Friday, March 13, 2009

Change the date format using PHP

If $month is currently Mar and your want March use

date("F",strtotime($month))

Simple