Access different array values

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 ?

$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

thanks alot friend. Igor

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.