I want to make json
as followsin php:
{["key1":"value1"],["key2":"value2"]}
Can any one help?
I want to make json
as followsin php:
{["key1":"value1"],["key2":"value2"]}
Can any one help?
See the PHP manual for json_encode()
and json_decode()
:
http://php.net/manual/en/function.json-encode.php http://php.net/manual/en/function.json-decode.php
You can do it like this: set it to true, if you want an associative array.
$array = json_decode('[{"var1":"9","var2":"16","var3":"16"},{"var1":"8","var2":"15","var3":"15"}]',true);
if you want to iterate:
foreach($array as $item) { //foreach element in $arr
$uses = $item['var1']; //etc
}