In this tutorial learn convert JSON format to array in php using a json_decode() example, Convert json to array using json_decode method in php, and output will generate with object and array.
Example index.php
<?php
$json = '{"Car":"Ferrari","Company":"torson","Phone":3232322123}';
//with Object Result
var_dump(json_decode($json));
//with Array Result
var_dump(json_decode($json, true));
The above example will output:
object(stdClass)#1 (3) { ["Car"]=> string(7) "Ferrari" ["Company"]=> string(6) "torson" ["Phone"]=> int(3232322123) }
array(3) { ["Car"]=> string(7) "Ferrari" ["Company"]=> string(6) "torson" ["Phone"]=> int(3232322123) }
No comments:
Post a Comment