-1

I want to make json as followsin php:

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

Can any one help?

3
  • 2
    That's not valid JSON Commented Dec 16, 2014 at 21:08
  • 1
    This doesn't make a whole lot of sense. Shouldn't the brackets be reversed? Commented Dec 16, 2014 at 21:08
  • Have you tried json_encode ? Commented Dec 16, 2014 at 21:11

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.