Reputation: 4564
I have the following value stored in mysql : a:3:{i:0;s:2:"35";i:1;s:2:"33";i:2;s:2:"50";}
when I use
$value= 'a:3:{i:0;s:2:"35";i:1;s:2:"33";i:2;s:2:"50";}'
$data_array = json_decode($value);
var_dump($data_array);
this returns null.how can I return the values, in this case its 35 33 and 50.
Upvotes: 1
Views: 119
Reputation: 7715
That is not JSON. It's a serialized array. Use unserialize()
instead of json_decode.
Upvotes: 4
Reputation: 54841
This is not json data. This is serialized data. Use unserialize
to get an array.
$value= 'a:3:{i:0;s:2:"35";i:1;s:2:"33";i:2;s:2:"50";}'
$data_array = unserialize($value);
var_dump($data_array);
Upvotes: 5