First step:
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
$str = json_encode($arr);
Is it possible to get the original array from $str
if I don't have easy access to $arr
?
First step:
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
$str = json_encode($arr);
Is it possible to get the original array from $str
if I don't have easy access to $arr
?
Yes, You can decode using json_decode
.
Use this to get original array.
$arr = json_decode($str,true)
for more detail click here
You can encode your arrays to JSON with
$encode = json_encode($array);
But you can also decode it. This way you get the original array back:
$decode = json_decode($encode);
Hope this helps you out :)