如何将格式数组上的字符串转换为数组[复制]

问题描述 投票:-2回答:1

这个问题在这里已有答案:

我有这种格式的字符串变量:

$array = '[{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}]';

我怎样才能从中获得价值

$array[0]['name']; //value is 'jack'
php arrays string converters
1个回答
0
投票

https://juderosario.com/2016/09/01/parsing-json-with-php/

好吧,我从那里得到它

$json = '[ {"id":"1", "name":"foo" }, {"id":"2", "name":"bar" } ]';
$baz = json_decode($json,true);

echo($baz[1]['name']); //bar
© www.soinside.com 2019 - 2024. All rights reserved.