How can I echo this PHP array with objects in an foreach loop?
I want to echo each value in different parts of my code.
array(2) {
["new_years_day"]=>
object(DateTime)#1 (3) {
["date"]=>
string(26) "2024-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "America/New_York"
}
["juneteenth"]=>
object(DateTime)#2 (3) {
["date"]=>
string(26) "2024-06-19 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "America/New_York"
}
}
I tried this code but it this doesn’t do the job ($holidaysThisYear is the name of the array):
<?php foreach($holidaysThisYear as $holidayThisYear) {
echo $holidayThisYear->timezone;
} ?>