我在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。
$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;
答案 0 :(得分:1)
对不起,问题出在逻辑上..计数器正在递增多次...谢谢你的帮助