我正在使用以下数组
Array
(
[0] => Array
(
[id] => 6
[key] => SITE_NAME
[value] => Webg Smarty CMS Small
[name] => general
[title] => website name
[type] => text
)
[1] => Array
(
[id] => 32
[key] => PHONE_NUMBER
[value] => 713-332-4675
[name] => general
[title] => Phone Number
[type] => text
)
)
我想显示[0] [值],[1] [值]
我正在使用foreach但我无法打印值
如何展示?
答案 0 :(得分:1)
<?php
//$arr = your nested array aboe
foreach($arr as $v){
echo $v['value']; //this will print 'Webg Smarty CMS Small' first in your example followed by '713-332-4675'
}
$arr[0]['value'] will give you 'Webg Smarty CMS Small'
$arr[1]['value'] will give you '713-332-4675'
答案 1 :(得分:0)
试试这个
foreach($yourArr as $key => $value)
{
echo $value['value'];
}
OR
echo $yourArr[0]['value']; //print value of first element
echo $yourArr[0]['key']; //print key of first element