I have an array with shops and working hours like this:
[0] => Array
(
[name] => Value1
[working_hours] => Array
(
[sunday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 6:00
)
)
[saturday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 6:00
)
[1] => Array
(
[0] => 19:30
[1] => 23:59
)
)
[tuesday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 4:00
)
[1] => Array
(
[0] => 19:30
[1] => 23:59
)
)
[friday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 4:00
)
[1] => Array
(
[0] => 19:30
[1] => 23:59
)
)
[thursday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 4:00
)
[1] => Array
(
[0] => 19:30
[1] => 23:59
)
)
[wednesday] => Array
(
[0] => Array
(
[0] => 00:00
[1] => 4:00
)
[1] => Array
(
[0] => 19:30
[1] => 23:59
)
)
[monday] => Array
(
[0] => Array
(
[0] => 19:30
[1] => 23:59
)
)
)
This is one record of the hundreds that I have to insert into db. I' ve made my bd table like this: hours_id INT, shop INT, day INT or VARCHAR(no problem), openTime TIME, closeTime TIME. So far my code is something like that: ...//code here
foreach ($row["hours"] as $h1) {
$day = $h_days["?"]; //how to put it here?
foreach ($h1 as $h2) {
foreach ($h2 as $hour) {
$openTime = $hour["0"];
$closeTime = $hour["1"];
$insert_items4 = mysql_query("INSERT INTO hours (shop, day, openTime, closeTime) VALUES ('".$var1."', '". $day."', '".$openTime."', '".$closeTime."')");
}
}
}
I found some examples with array_map like this $days = array_map('mysql_real_escape_string', array_values($row["hours"])); or something like this $keys = implode(', ', array_keys($row["hours"])); but i don't know how to use them exactly. How can I insert the days of each record with their open and close time? I searched but I can't find something like this. Thanks in advance