[英]php multidimensional array keys
大家好,我在使用 php 数组时遇到了一些麻烦。 给定一个数组 $all_array 并且当我 var_dump 它时,php 会在下面显示这些信息。
Array (
[0] => Array (
[textQm_id] => 8
[textQtxt] => lorem ipsu dolor title 1
)
)
Array (
[0] => Array (
[questionQs_id] => 17
[questionQm_id] => 8
[questionQsuraq] => Lorom ipsum dolor question 1?
)
)
Array (
[0] => Array (
[questionQs_id] => 18
[questionQm_id] => 10
[questionQsuraq] => Lorom ipsum dolor question 2?
)
)
.
.
.
Array (
[0] => Array (
[textQm_id] => 9
[textQtxt] => lorem ipsu dolor title 9
)
)...
如何获取 textQtxt 值?
Array (
[0] => Array (
// try to get the key by index I believe is index 1, then compare key word with the keyword you have of textQtxt then you fetch the value
if ( [key index] == "textQtxt" )
{
//get the value
}
)
)
环顾函数array_column ,看起来像是您问题的精确解决方案。 否则尝试“展平”数组,然后查找值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.