如何使其更简单(意味着我不想使用多维数组)我只想一次只访问一行。将此多维3级深度数组转换为2级深度或1级深度数组,以便可以在PHP中轻松访问)
Array
(
[0] => Array
(
[0] => Array
(
[id] => 2
[name] => 22" 120g Honey Comb
[sku] => Sonia-22
[price] => 100
[qty] => 74
[image] =>
[description] =>
[attribute_value_id] => null
[brand_id] => null
[category_id] => null
[store_id] => 3
[availability] => 1
)
[1] => Array
(
[id] => 4
[name] => Side Fringe2
[sku] => FrSideHH#1B-WU
[price] => 150
[qty] => 195
[image] =>
[description] =>
[attribute_value_id] => null
[brand_id] => ["1"]
[category_id] => ["5"]
[store_id] => 3
[availability] => 1
)
)
)
如何使其更简单(意味着我不想使用多维数组)我只想一次只访问一行。将此多维3级深度数组转换为2级深度或1级...
您的varDump通过它的外观显示了一个有许多子级的父数组,因此解决它的最简单方法如下:
foreach($mainArray[0] as $child){
foreach($child as $row){
echo $row['name'] . "\n";
}
}