note 44637 deleted from function.serialize by aharvey

From: Date: Tue, 06 Nov 2012 02:04:40 +0000
Subject: note 44637 deleted from function.serialize by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191748@lists.php.net to get a copy of this message
Note Submitter: goetas at lignano dot it - GoetAs ---- 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); } ?>

« previous php.notes (#191748) next »