[英]Printing an associative array inside a numerical array with PHP
I have a numerical array for which each row is an associative array. 我有一个数值数组,其每一行都是一个关联数组。 A var_dump on this array is like : 此数组上的var_dump类似于:
array (size=4)
0 =>
array (size=1)
'brand' => string 'Daewoo' (length=6)
1 =>
array (size=1)
'brand' => string 'Honda' (length=5)
2 =>
array (size=1)
'brand' => string 'Mazda' (length=5)
How can I loop through this multi-dimensional array to show in a select/option the value of the key "brand" ? 如何遍历此多维数组以在选择/选项中显示键“ brand”的值?
I tried something like a for loop with a foreach loop inside but my associative array has no name, it's not declared as a variable. 我尝试了一个for循环,里面有一个foreach循环,但是我的关联数组没有名称,它没有声明为变量。
Any idea ? 任何想法 ?
How about this: 这个怎么样:
foreach ($numerical_array AS $row) {
print ("<option>" . $row['brand'] . "</option>");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.