I have the following code:
<?php
$dates = array('2014-12-01','2014-12-02','2014-12-08','2014-12-09','2014-12-10','2014-12-11');
$values = array(5,3,7,8,9,2);
foreach ($dates as $date){
//Array of the regarded days names is generated
$days[] = strtolower(date('l', strtotime($date)))."\n";
}
for ($i = 0; $i < count($days); $i++){
$day = $days[$i];
$$day = $values[$i];
}
echo $monday;
?>
echo $monday does not print any value, I expect it to print 8, because in the last loop I had a variable named with the value of $day and the last setting for that value should be 8. So why it does not set correctly?!
This is a demo: http://codepad.org/VDIyBuq3