How To pass an Array in the Querystring Using PHP

I recently ran across a silly Wordpress situation where I needed to pass an array in the querystring.  Here’s what I came up with:

$array = array('a' => 1, 'b' => 2, 'c' => 3);
$array = rawurlencode(serialize($array));
echo '<a href="./getarray.php?a=' . $array . '">Pass array</a>';

Then on the receiving getarray.php:

$array = unserialize(stripslashes($_GET['error_array']));

Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: