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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.