0
我在php中有这个关联数组。在这最后的指数有另一个数组...我试图打印ID,但无法做到plz帮助我呼应id的值如何打印不同大小的关联数组
array (size=1)
2 =>
array (size=8)
'id' => int 32 /// this is I want to echo
'uid' => int 2
'title' => string ' a type s' (length=9)
'price' => int 555555
'cat' => string 'Car' (length=3)
'usage' => string 'used' (length=4)
'desc' => string 'which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum gen' (length=200)
'img' =>
array (size=2)
'img_id' => int 2
'img_name' => string 'image_2014-09-18-22-10-59_541b3c53b5e12.jpeg' (length=44)
数组变量名是$广告。
$ad_set = Array (
'id' => $id, /// Want to echo this
'uid' => $uId,
'title' => $title,
'price' => $price,
'cat' => $cat,
'usage' => $usage,
'desc' => $desc,
'img' => $a_img
);
try {
$ads [$count] = $ad_set;
} catch (Exception $exc) {
echo $exc->getTraceAsString();
}
$count ++;
return $ads;
'回声$广告[2] [ 'IMG'] [ 'img_id']' – Ghost 2014-09-19 15:58:38
没有我试图仅回显'id'索引... – Umerm 2014-09-19 15:59:53
很简单。抓住数组'$ ad_set',然后获取数组中的索引,'[2]',然后获取您之后的键值,'['id']'。 – Ohgodwhy 2014-09-19 16:02:28