tanphatle
(Letanphat0706)
1
I have an array:
array(1) {
[0]=> array(10) {
["kind_of_promotion"]=> int(1)
["id"]=> string(1) "0"
["id_book"]=> string(4) "6184"
["id_book_source"]=> string(3) "347"
["id_cat"]=> NULL
["barcode"]=> NULL
["date_released"]=> string(10) "1401728460"
["qty"]=> string(1) "1"
["image"]=> string(0) ""
["name"]=> string(46) "GREEN TECHNOLOGY AND SUSTAINABLE DEVELOPMENT 1"
}
}
I want to get "id_book" in this array, how to get it ? help me please !
Keith
(Kburton)
2
$bookId = $arrayName[0]['id_book'];
jmunozdev
(Jmunoz Dev)
3
If you wanna iterate over the nested array for retrieve all booking_id for example, you should use a foreach like this:
foreach ($data as $key => $value) {
$bookId = $value['id_book'];
$Id = $value['id'];
//whatever you wanna retrieve for the 2nd array
}
tanphatle
(Letanphat0706)
4
Thanks for reply, i have tried 2 ways but it didn’t work,all i get is NULL
inradius
(Stroud Travis)
5
Both answers should work. Can you show your PHP code?
tanphatle
(Letanphat0706)
6
OMG !!! my mistake, it has worked. Thanks all