我有1個JSON,但我不能使用用於循環我不能使用環路(PHP)得到JSON數組值
$string = [{"lt":"1","lot":["1","1","1","1","1"]},{"lt":"2","lot":["0","0","0","0","0"]},{"lt":"3","lot":["0","0","0","0","0","0"]}]
$json = json_decode($string,true);
for($i = 0;$i<count($json);$i++){
for($j = 0;$j<count($json->lot);$i++){
if($json->lot==0){
echo $j;
}
}
}
得到一個值i得到這個錯誤:試圖得到非對象
的屬性
$ JSON是數組,使用'$ JSON [ '很多']',而不是'$ json-> lot' –