如何将格式数组上的字符串转换为数组

时间:2019-04-06 08:10:31

标签: php arrays string converters

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

""

我如何从中获得价值

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

1 个答案:

答案 0 :(得分: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