How to decode a JSON string in PHP

2 Answers

0 votes
$json = '{"a":1,"b":2,"c":3}';

echo "<pre>";
var_dump(json_decode($json));
echo "</pre>";

/*
run: 

object(stdClass)#1 (3) {
  ["a"]=>
  int(1)
  ["b"]=>
  int(2)
  ["c"]=>
  int(3)
}

*/

 



answered Jul 2, 2016 by avibootz
0 votes
$json = '{"a":1,"b":2,"c":3}';

echo "<pre>";
var_dump(json_decode($json, true));
echo "</pre>";

/*
run: 

array(3) {
  ["a"]=>
  int(1)
  ["b"]=>
  int(2)
  ["c"]=>
  int(3)
}

*/

 



answered Jul 2, 2016 by avibootz

Related questions

...