0
我有一個json_encode格式的數據庫值。echo json_decode php中的數據
[["Size: 10x24 (+150)","Backing: Black","Lines: 1","Border: No Border","Border Color: ","Flashing: No Thanks","Outdoor: No","Vertical: No","contoured cut: No","qty: 1","Text 1: Custom","Line 1: Red","Font 1: Arial"]]
我想在表格中顯示它的json_decode
格式。
$options = json_decode($options, true);
然後我試圖把它放在foreach循環:
foreach ($options as $value)
{
echo $value, "\n";
};
和輸出僅僅是Array
。
echo('<pre>'); print_r($json); echo('</pre>');
print_r()
回報:
Array
(
[0] => Array
(
[0] => Size: 10x24 (+150)
[1] => Backing: Black
[2] => Lines: 1
[3] => Border: No Border
[4] => Border Color:
[5] => Flashing: No Thanks
[6] => Outdoor: No
[7] => Vertical: No
[8] => contoured cut: No
[9] => qty: 1
[10] => Text 1: Custom
[11] => Line 1: Red
[12] => Font 1: Arial
)
)
但它並不好看。這是更好和簡單的方法來在php中回顯json_decode數據?
你有一個數組的數組,所以你可以嘗試foreach($ options [0]作爲$ value),看看是否有效。 – jeff
你想要哪種數據? – 2016-12-28 06:47:04