newsomjk Posted July 19, 2013 Share Posted July 19, 2013 So basically, this string is in the database and I can't find what saved it so I'm not sure what method they used to create the string... But I need to break it into an array. I tried originally using $array = unserialize($str), however that printed "not ok." This method prints "ok" however, nothing shows up afterwards. $str = '{"media_id":"235","stream":"0","maxspeed":"3000","maxloads":"0","mloadperInterval":"0","mloadInterval":"0","maxtime":"0","publish_up":"0","publish_down":"0"}'; echo $str; $array = json_decode($str); if ($array !== false) { echo "ok"; } else { echo "not ok"; } echo '<br/><br/>'.print_r($array,true); What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/280321-simple-serialized-string-not-being-unserialized/ Share on other sites More sharing options...
AbraCadaver Posted July 19, 2013 Share Posted July 19, 2013 Dunno. If I run your code I get: {"media_id":"235","stream":"0","maxspeed":"3000","maxloads":"0","mloadperInterval":"0","mloadInterval":"0","maxtime":"0","publish_up":"0","publish_down":"0"}ok stdClass Object ( [media_id] => 235 [stream] => 0 [maxspeed] => 3000 [maxloads] => 0 [mloadperInterval] => 0 [mloadInterval] => 0 [maxtime] => 0 [publish_up] => 0 [publish_down] => 0 ) Link to comment https://forums.phpfreaks.com/topic/280321-simple-serialized-string-not-being-unserialized/#findComment-1441402 Share on other sites More sharing options...
mac_gyver Posted July 19, 2013 Share Posted July 19, 2013 your code works for me. best guess that code is inside of some other output that is hiding it in the 'view source' in your browser. btw - if you truly want an array as a result, use a true value as the second parameter in $array = json_decode($str,true); Link to comment https://forums.phpfreaks.com/topic/280321-simple-serialized-string-not-being-unserialized/#findComment-1441403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.