I have array like this:
$storeSchedule = [
'Mon' => ['08:00 AM' => '12:00 PM'],
'Tue' => ['08:00 AM' => '05:00 PM'],
'Wed' => ['08:00 AM' => '05:00 PM'],
'Thu' => [['08:00 AM' => '12:00 PM'] , ['01:00 PM' => '05:30 PM']],
I needed to add more than one period to same day and access both values. I tried looping like that
> foreach ($storeSchedule[date('D', strtotime($currentTime))] as $startTime => $endTime) {
but I get only one value, what I should do to access the other values ?
igor_g
4
$storeSchedule = [
'Mon' => [['arriving' => '08:00 AM', 'departure' => '12:00 PM']],
'Tue' => [['arriving' => '08:00 AM', 'departure' => '05:00 PM']],
'Wed' => [['arriving' => '08:00 AM', 'departure' => '05:00 PM']],
'Thu' => [
['arriving' => '08:00 AM', 'departure' => '12:00 PM'],
['arriving' => '01:00 PM', 'departure' => '05:30 PM']
],
$weekDay = date('D', strtotime($currentTime));
foreach ($storeSchedule[weekDay] as $times) {
// $times = ['arriving' => '...', 'departure' => '...']
}
1 Like
system
Closed
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.