Answer the question
In order to leave comments, you need to log in
I ask for help how to make a nested array from a database selection?
Good day to all friends, I have a question how can I convert the 2 arrays below to 1 by the album_id and book_id keys, if they differ in the array, or how can I immediately do it from the database.
[0]=>
array(6) {
["album_id"]=>
int(1)
["type"]=>
int(1)
["album"]=>
string(16) "я на море"
["usr_id"]=>
int(1)
["date_album"]=>
string(19) "2017-09-06 18:37:31"
["book"]=>
array(4) {
["book_id"]=>
int(1)
["book_name"]=>
string(11) "книга1"
["alb_id"]=>
int(1)
["photo"]=>
array(8) {
["photo_id"]=>
int(1)
["bk_id"]=>
int(1)
["picture"]=>
string(10) "photo1.jpg"
["url"]=>
string(65) "188.225.82.218/content/users/albums/email/Я на море/book1/"
["location"]=>
string(28) "Украина, Одесса"
["annotation"]=>
string(13) "бла-бла"
["date_photo"]=>
string(10) "22.07.2017"
["date_picture"]=>
string(19) "2017-09-06 18:26:12"
}
}
}
[1]=>
array(6) {
["album_id"]=>
int(1)
["type"]=>
int(1)
["album"]=>
string(16) "я на море"
["usr_id"]=>
int(1)
["date_album"]=>
string(19) "2017-09-06 18:37:31"
["book"]=>
array(4) {
["book_id"]=>
int(1)
["book_name"]=>
string(11) "книга1"
["alb_id"]=>
int(1)
["photo"]=>
array(8) {
["photo_id"]=>
int(2)
["bk_id"]=>
int(1)
["picture"]=>
string(10) "photo2.jpg"
["url"]=>
string(65) "188.225.82.218/content/users/albums/email/Я на море/book1/"
["location"]=>
string(28) "Украина, Одесса"
["annotation"]=>
string(13) "бла-бла"
["date_photo"]=>
string(10) "22.07.2017"
["date_picture"]=>
string(19) "2017-09-06 18:26:12"
}
}
}
[2]=>
array(6) {
["album_id"]=>
int(1)
["type"]=>
int(1)
["album"]=>
string(16) "я на море"
["usr_id"]=>
int(1)
["date_album"]=>
string(19) "2017-09-06 18:37:31"
["book"]=>
array(4) {
["book_id"]=>
int(1)
["book_name"]=>
string(11) "книга1"
["alb_id"]=>
int(1)
["photo"]=>
array(8) {
["photo_id"]=>
int(3)
["bk_id"]=>
int(1)
["picture"]=>
string(10) "photo3.jpg"
["url"]=>
string(65) "188.225.82.218/content/users/albums/email/Я на море/book1/"
["location"]=>
string(28) "Украина, Одесса"
["annotation"]=>
string(13) "бла-бла"
["date_photo"]=>
string(10) "22.07.2017"
["date_picture"]=>
string(19) "2017-09-06 18:26:12"
}
}
}
[3]=>
array(6) {
["album_id"]=>
int(3)
["type"]=>
int(1)
["album"]=>
string(8) "дача"
["usr_id"]=>
int(1)
["date_album"]=>
string(19) "2017-09-07 13:10:19"
["book"]=>
array(4) {
["book_id"]=>
NULL
["book_name"]=>
NULL
["alb_id"]=>
NULL
["photo"]=>
array(8) {
["photo_id"]=>
NULL
["bk_id"]=>
NULL
["picture"]=>
NULL
["url"]=>
NULL
["location"]=>
NULL
["annotation"]=>
NULL
["date_photo"]=>
NULL
["date_picture"]=>
NULL
}
}
}
}
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