note 113618 deleted from function.json-encode by crell
| From: | crell@php.net | Date: | Fri, 01 Jul 2022 19:24:17 +0000 |
| Subject: | note 113618 deleted from function.json-encode by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218833@lists.php.net to get a copy of this message | ||
Note Submitter: info at pkrules dot in
----
Notice the last json_decode does not working :) ,you need to use a variable to use the encoded data
in json_decode():-
<?php
$arr=array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr)."<br />";
//{"a":1,"b":2,"c":3,"d":4,"e":5}
print_r (json_decode(json_encode($arr)));
//stdClass Object ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 )
echo "<br />";
$var=json_encode($arr);
print_r (json_decode($var,true));
//Array ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 )
echo "<br />";
print_r (json_decode(json_encode($arr)),true);//no output
?>