Answer the question
In order to leave comments, you need to log in
How to iterate over a multidimensional array and merge elements by key?
There is such an array of addresses. The task is to display a block of information: city + address, phone number and opening hours of all establishments in this city. In this case, you need to output:
"
Moscow:
Leningradsky prospect, 26k1, 8 985 475-44-44, Daily from 12:00 to 21:00
Lenina st. 17, +7 888 888 88 88, Daily from 10:00 to 20:00
Almaty: Kurmangazy 31, corner
of
Kunaev street 171, +7 771 411-14-30, Daily from 10:00 to
19:00
array(3) {
[0]=>
array(5) {
["MIGX_id"]=>
string(1) "1"
["city"]=>
string(12) "Москва"
["address"]=>
string(53) "Ленинградский проспект, д 26к1"
["phone"]=>
string(15) "8 985 475-44-44"
["workhours"]=>
string(38) "Ежедневно с 12:00 до 21:00"
}
[1]=>
array(5) {
["MIGX_id"]=>
string(1) "2"
["city"]=>
string(12) "Алматы"
["address"]=>
string(62) "Курмангазы 31, угол ул. Кунаева д. 171"
["phone"]=>
string(16) "+7 771 411-14-30"
["workhours"]=>
string(38) "Ежедневно с 10:00 до 19:00"
}
[2]=>
array(5) {
["MIGX_id"]=>
string(1) "3"
["city"]=>
string(12) "Москва"
["address"]=>
string(62) "ул. Ленина 17"
["phone"]=>
string(16) "+7 888 888 88 88"
["workhours"]=>
string(38) "Ежедневно с 10:00 до 20:00"
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question