这是我的数组,我只能从该数组中获得名称,所以我如何才能获得
[
{
"name":"imgpsh_fullsize_anim_31.png",
"type":"image/png",
"tmp_name":"/tmp/phpcaGk0O",
"error":"0",
"size":"34171",
"file":"imgpsh_fullsize_anim_31.png",
"cookie":
{
"name":"admin",
"value":"s3jbpiubqq13tsrase0d4e6cma",
"lifetime":"900000",
"path":"/nback",
},
"previewType":"image"
}
]
我假设这是您手中的JSON字符串,所以基本上:
$arr = json_decode($str, true);
$name = $arr[0]["name"];
如果调用数组$myArray
,则只提取变量名称,如下所示:
$name = $myArray->name;
如果是JSON:
$myJSONArray = json_decode($myArray);
$name = $myJSONArray[0]["name"];