-1

I've a string like this:

$mystring = '{"1":"4","2":"2","3":"3"}';

I need to explode to something like this:

array(
  "1" => "4",
  "2" => "2",
  "3" => "3"
)

I use php 5.4.

Selman Genç
  • 100,147
  • 13
  • 119
  • 184

3 Answers3

1

Just use json_decode.

$dd = json_decode($mystring, true);
var_export($dd);
cornelb
  • 6,046
  • 3
  • 19
  • 30
1

you "string" is very like json so maybe try json_decode()

Peter
  • 16,453
  • 8
  • 51
  • 77
0

you should use the json decode function, your string looks like json. The second argument tells to make it as an array, not an object.

json_decode($mystring, true);