note 45347 added to function.unserialize
| From: | pfister at avenir dot de | Date: | Thu, 02 Sep 2004 21:25:25 +0000 |
| Subject: | note 45347 added to function.unserialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75960@lists.php.net to get a copy of this message | ||
Having had a problem with an mysql-stored serialized array which I had edited I found out that
unserialize seems to have got a problem with "\r" within the string I wanted to
unserialize.
It simply quits it's job with "false".
To work arround this problem I just replaced \r with "":
<?php
$serializedArray = 'a:1:{i:0;a:2:{s:4:"name";s:70:"Here comes the
newline\r\nthis is the new line";s:5:"value";d:2.20;}}';
var_dump(unserialize($serializedArray)); //This just outputs bool(false)
$serializedArray = str_replace("\r", "", $serializedArray);
var_dump(unserialize($serializedArray)); //This outputs the array structure
?>
----
Manual Page -- http://www.php.net/manual/en/function.unserialize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45347
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45347&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45347&report=yes
Search -- http://master.php.net/manage/user-notes.php