Jump to content

[SOLVED] Passing an array in the URL


mellis95

Recommended Posts

I am trying to pass an entire array through the URL without using POST. From what I have found with Google searches, it seems that I should be able to implode the array and pass it as follows:

 

$d = implode(',', $clean);

and then further down the code, do this:

 

<META HTTP-EQUIV="refresh" content="0;URL=http://localhost/td/ref/deny.php?d=$d">

 

On deny.php, I then try to explode the array back to a useable state:

 

$d=$_GET['d'];
$clean = explode(",", $d);

 

However, when I implode the array on the first page, it shows up in the URL as

http://localhost/td/ref/deny.php?d=Array

and I get nothing when I try to echo array elements on the deny.php page.

 

Am I barking up the wrong tree here? I have never tried to pass an array this way before.

 

Thanks for the help.

 

Matt

Link to comment
https://forums.phpfreaks.com/topic/173700-solved-passing-an-array-in-the-url/
Share on other sites

Or the array is multidimensional. And if one of the array values contains a comma, you won't end up with the same array as you started with. You can use rawurlencode(serialize($clean)) to convert the array to an (escaped) string, and then unserialize(rawurldecode($_GET['d'])) to convert it back to an array on your second page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.