data setup
# original dates, used to instantiate DateTime objects
$ds = array( DateTime::createFromFormat('Y-m-d', '2011-07-30'),
DateTime::createFromFormat('Y-m-d', '2011-07-30'),
DateTime::createFromFormat('Y-m-d', '2011-07-31'),
DateTime::createFromFormat('Y-m-d', '2011-08-01')
);
# change dates into days, represented as "Mon", "Tue" etc
foreach($ds as &$d)
{
$d = $d->format('D');
}
stylesheet
# create css style rules based on the above
.Mon { color: #FFF; }
.Tue { color: #F00; }
.WED { color: #0F0; }
output
# use the class attribute to make the css styles apply to each element as needed
foreach ($ds as $d)
{
printf('<div class="%s">%s</div>', $d, $rowData);
}