I have a multidimensional array and it is like this:
Array
(
[Monday] => Array
(
[open] => 05.00 PM
[close] => 04.00 PM
[state] => 0
)
[Tuesday] => Array
(
[open] =>
[close] =>
[state] => 1
)
[Wednesday] => Array
(
[open] => 03.00 AM
[close] => 06.00 PM
[state] => 0
)
[Thursday] => Array
(
[open] =>
[close] =>
[state] => 1
)
[Friday] => Array
(
[open] => 05.00 PM
[close] => 03.00 PM
[state] => 0
)
[Saturday] => Array
(
[open] => 05.00 PM
[close] => 06.00 PM
[state] => 0
)
[Sunday] => Array
(
[open] =>
[close] =>
[state] => 1
)
)
Using this array I want to create output like this:
Monday - 05.00 PM - 04.00 PM
Tuesday - Closed
Wednesday - 03.00 AM - 06.00 PM
Thursday - Closed
Friday - 05.00 PM - 03.00 PM
Saturday - 05.00 PM - 06.00 PM
Sunday - Closed
I tried it with 2 foreach loops, but I couldn't get it to show the expected output.
foreach ($result as $days => $values) {
echo "$days";
foreach ($values as $k) {
echo " - $k";
}
echo "<br/>";
}
Its output is similar to this:
Monday - 05.00 PM - 04.00 PM - 0
Tuesday - - - 1
Wednesday - 03.00 AM - 06.00 PM - 0
Thursday - - - 1
Friday - 05.00 PM - 03.00 PM - 0
Saturday - 05.00 PM - 06.00 PM - 0
Sunday - - - 1
Can anybody tell me how can I figure this out?
NOTE: if state = 0
it doesn't need to display and state = 1
it should be Closed