-2

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?

Tanner Quigley
  • 246
  • 4
  • 12

3 Answers3

2

Yes, You can decode using json_decode. Use this to get original array.

$arr = json_decode($str,true)

for more detail click here

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
0
$str = json_decode($str);

Google is your friend, failing that php.net

Christopher Shaw
  • 763
  • 6
  • 19
0

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 :)

Melvin Koopmans
  • 2,994
  • 2
  • 25
  • 33