Hi everyone,
I'm trying to loop through an array and modify the array keys:
PHP Code:
foreach($dates as &$key => $value) {
if($key == $today) {
$key = 'Today';
} elseif($key == $yesterday) {
$key = 'Yesterday';
} elseif(date('W', strtotime($key)) == $thisweek) {
$key = date('l', strtotime($key));
} else {
$key = date('l jS F');
}
}
When I run this code I get a blank page (despite error_reporting being set to E_ALL at the top - how helpful).
When I remove the & from in front of $key it runs, but obviously doesn't modify the key of the $dates array. It would seem that PHP doesn't allow you to pass the keys by reference, but I can't believe that this is the problem.
Anyone know what's up here?
Thanks
Bookmarks