note 45347 deleted from function.unserialize by aharvey
| From: | aharvey@php.net | Date: | Tue, 06 Nov 2012 01:18:41 +0000 |
| Subject: | note 45347 deleted from function.unserialize by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191690@lists.php.net to get a copy of this message | ||
Note Submitter: pfister at avenir dot de
----
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
?>