-1

I want to make json as followsin php:

{["key1":"value1"],["key2":"value2"]}

Can any one help?

Rizier123
  • 58,877
  • 16
  • 101
  • 156
user3691240
  • 45
  • 2
  • 7

2 Answers2

0

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

mopo922
  • 6,293
  • 3
  • 28
  • 31
0

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
}
AngularLover
  • 364
  • 1
  • 12