I have an array ($datesandadults) with pairs of values which are the date and the number of people:
Array (
[0] => stdClass Object (
[thedate] => April 9, 2016
[theadults] => 6
)
[1] => stdClass Object (
[thedate] => April 10, 2016
[theadults] => 9
)
...
I need to modify thedate value then put everything back into a new similar structured array. my code doesn't work, all it gives is:
Array (
[0] => date
[1] => adults
[thedate] => 2016-04-09
[adults] => )
The code I am using is:
$final_results = array('thedate','adults');
foreach ($datesandadults as $res2) {
foreach( $res2 as $key => $value) {
if ($key=='thedate') {
$actualtime=strtotime($value);
$value = date('Y-m-d', $actualtime);
}
$final_results[thedate] = $res2->thedate;
$final_results[adults] = $res2->adults;
}
}
I know my current code is nonsense but maybe will give an idea what I need..