嘿,我一直在努力,DECODE這樣我的JSON數據: `無效參數
$json = file_get_contents("http://localhost/php/service.php?rquest=searcht&user=".$user);
$final_res = html_entity_decode($json);
foreach ($final_res as $thedata->user)
{
foreach ($thedata as $value) { ?>
<tr>
<td ><? echo $value['No']?> </td>
<td><?echo $value['user']?></td>
}
}
` 解碼數據正常工作與輸出JSON,但是當我試圖foreach的JSON數據,它does not工作,但..在其他情況下,我用這種foreach以相同的方式打印我的數據與選擇*數據查詢到其他頁面。它的工作,但我使用這種foreach以相同的方式,但輸出爲foreach()提供的無效參數請告訴我,如果我犯了一個錯誤...
嘗試使用var_dump()來查看傳遞給foreach()循環的參數的數據類型。 –
你在哪裏解碼json?它根本沒有調用json_decode。 –
更新我一直在這樣解碼:$ final_res = html_entity_decode($ json); $ final_res1 = json_decode(stripslashes($ final_res));但foreach不起作用 – user3511548