1

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.

2
  • 3
    thats invalid JSON... Commented Jun 6, 2013 at 18:42
  • yeah thats unserialize. thanks sorry I missed that Commented Jun 6, 2013 at 18:43

2 Answers 2

5

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);
Sign up to request clarification or add additional context in comments.

Comments

4

That is not JSON. It's a serialized array. Use unserialize() instead of json_decode.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.