Jump to content

Simple serialized (?) string not being unserialized


newsomjk

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.