Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question
3  
thats invalid JSON... – Christian Gärtner Jun 6 at 18:42
2  
unserialize in php – Srikanth Kolli Jun 6 at 18:43
yeah thats unserialize. thanks sorry I missed that – fogsy Jun 6 at 18:43
Please accept an answer if it satisfies your question :] – phatskat Jun 6 at 18:48

2 Answers

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

share|improve this answer

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);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.