我现在正在使用以下代码:
$json = json_decode($content, true);
var_dump($json);
echo $json[0]['article'];
var_dump($json);
array(36) {
[0]=> string(53) "{"article":"Milk","==":"RandomString"}"
[1]=> string(56) "{"article":"Water","==":"RandomString"}"
[2]=> string(68) "{"article":"Beef","amount":3,"==":"RandomString"}"
[3]=> string(4) "null" [4]=> string(4) "null" [5]=> string(4) "null" [6]=> string(4) "null" [7]=> string(4) "null" [8]=> string(4) "null" [9]=> string(4) "null" [10]=> string(4) "null" [11]=> string(4) "null" [12]=> string(4) "null" [13]=> string(4) "null" [14]=> string(4) "null"
}
但它返回:
Warning: Illegal string offset 'article' in json.php on line 17
{
(是的,最后的 { 也输出了)
任何人都知道我怎样才能正确获得这个数组?如果设置了金额,我怎么能得到金额?