如何使用php解码它
$myjson = [{"type":"laser","material":"1","quantity":1000},
{"type":"motors","material":"1","quantity":1491477212},
{"type":"shield","material":"1","quantity":1491531189},
{"type":"hp","material":"1","quantity":1491531201}] ;
答案 0 :(得分:0)
检查此代码,您错过了"'"在开始和结束"'"。我现在格式化你可以使用这个代码
<?php
$myjson = '[{"type":"laser","material":"1","quantity":1000},{"type":"motors","material":"1","quantity":1491477212},{"type":"shield","material":"1","quantity":1491531189},{"type":"hp","material":"1","quantity":1491531201}]' ;
$array = json_decode($myjson);
echo "<pre>";
print_r($array);