note 44637 added to function.serialize
| From: | goetasatlignanodotit-GoetAs at osu1 dot php dot net | Date: | Wed, 11 Aug 2004 17:41:32 +0000 |
| Subject: | note 44637 added to function.serialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-74481@lists.php.net to get a copy of this message | ||
the serialize dont function properly when a variable contain a ;
I wrote these two functions that resolve this problem:
this function work only with arrays:
<?php
function base64_unserialize($str){
$ary = unserialize($str);
if (is_array($ary)){
foreach ($ary as $k => $v){
if (is_array(unserialize($v))){
$ritorno[$k]=base64_unserialize($v);
}else{
$ritorno[$k]=base64_decode($v);
}
}
}else{
return false;
}
return $ritorno;
}
function base64_serialize($ary){
if (is_array($ary)){
foreach ($ary as $k => $v){
if (is_array($v)){
$ritorno[$k]=base64_serialize($v);
}else{
$ritorno[$k]=base64_encode($v);
}
}
}else{
return false;
}
return serialize ($ritorno);
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.serialize.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44637
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44637&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44637&report=yes
Search -- http://master.php.net/manage/user-notes.php