mellis95 Posted September 9, 2009 Share Posted September 9, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/173700-solved-passing-an-array-in-the-url/ Share on other sites More sharing options...
rhodesa Posted September 9, 2009 Share Posted September 9, 2009 What is the entire code...my guess is you change the value of $d between this line: $d = implode(',', $clean); and this one: <META HTTP-EQUIV="refresh" content="0;URL=http://localhost/td/ref/deny.php?d=$d"> Quote Link to comment https://forums.phpfreaks.com/topic/173700-solved-passing-an-array-in-the-url/#findComment-915634 Share on other sites More sharing options...
thebadbad Posted September 9, 2009 Share Posted September 9, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/173700-solved-passing-an-array-in-the-url/#findComment-915647 Share on other sites More sharing options...
mellis95 Posted September 9, 2009 Author Share Posted September 9, 2009 Thanks for the help. Using rawurlencode(serialize) did the job. Quote Link to comment https://forums.phpfreaks.com/topic/173700-solved-passing-an-array-in-the-url/#findComment-915660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.