我有一个看起来像
的数组$arr = array(
array('contents' => "any value",
'tags' => '<th>'
),
array('contents' => "any value",
'tags' => "<th>"
)
.
.
.
);
我想回应索引&#34;内容&#34;
的价值答案 0 :(得分:1)
使用此(但您应该检查文档以提高您对阵列的了解):
$arr = array(
array('contents' => "any value",
'tags' => '<th>'
),
array('contents' => "any value",
'tags' => "<th>"
)
);
foreach ($arr as $token){
echo $token['contents'];
}
答案 1 :(得分:0)
试试这个
$arr = array(array('contents' => "any value", "tags" => "<th>"),array('contents' => "any value","tags" => "<th>"));
foreach($arr as $arrays){
echo $arrays["contents"];
}
答案 2 :(得分:0)
array_walk
对于这些事情非常有用。它遍历数组的每个元素并应用回调函数:
array_walk($arr, function($x) { if (isset($x['contents'])) echo $x['contents']; });
也许更简单,你可以自己循环遍历这些元素:
foreach ($arr as $a) {
if (isset($a['contents'])) echo $a['contents'];
}
答案 3 :(得分:-2)