note 19357 added to function.unserialize

From: Date: Mon, 25 Feb 2002 15:01:43 +0000
Subject: note 19357 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-27006@lists.php.net to get a copy of this message
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>'; } ?> -- http://www.php.net/manual/en/function.unserialize.php http://master.php.net/manage/user-notes.php?action=edit+19357 http://master.php.net/manage/user-notes.php?action=delete+19357 http://master.php.net/manage/user-notes.php?action=reject+19357

« previous php.notes (#27006) next »