note 19357 deleted from function.unserialize by sniper

From: Date: Mon, 13 Oct 2003 03:21:32 +0000
Subject: note 19357 deleted from function.unserialize by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58505@lists.php.net to get a copy of this message
Note Submitter: richard@richardhayes.net ---- If you have had the same problem as me: trying to unserialize an array passed through a query string. Cut and paste the below code for a working example. When unserializing you have to carry out stripslashes() and urldecode() before calling unserialize(). <? if( isset($ser1) ) { $ser1=stripslashes($ser1); $arr1 = urldecode($ser1); $arr1 = unserialize($arr1); echo 'First four elements of array:'; echo'<br>'. $arr1[0] . '<br>' . $arr1[1] . '<br>' . $arr1[2] . '<br>' . $arr1[3] . '<br>'; } else { $arr[] = 'First'; $arr[] = 'Second'; $arr[] = 'Third'; $arr[] = 'Forth'; $ser = serialize($arr); $ser = urlencode($ser); echo '<a href="' . $PHP_SELF . '?ser1=' . $ser . '">Pass</a>'; } ?>

« previous php.notes (#58505) next »