php multidimensional array get values

前端 未结 2 558
借酒劲吻你
借酒劲吻你 2020-12-13 07:23

This is my array in php $hotels

Array
(
    [0] => Array
        (
        [hotel_name] => Name
        [info] => info
        [roo         


        
2条回答
  •  再見小時候
    2020-12-13 07:39

    This is the way to iterate on this array:

    foreach($hotels as $row) {
           foreach($row['rooms'] as $k) {
                 echo $k['boards']['board_id'];
                 echo $k['boards']['price'];
           }
    }
    

    You want to iterate on the hotels and the rooms (the ones with numeric indexes), because those seem to be the "collections" in this case. The other arrays only hold and group properties.

提交回复
热议问题