What is the syntax for passing an array through the url?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Yourchild
Forum Newbie
Posts: 16
Joined: Mon Jul 30, 2007 3:04 pm

What is the syntax for passing an array through the url?

Post by Yourchild »

I have an array in page 1 such as this:

$myArray[0] =1;
$myArray[1] = 2;


etc etc....



I want to pass this array through the url into page 2:

header("Location: ".myURLAndDir()."invited.php"."?type=massmail"."&thisArray=".$myArray);

Is this the correct syntax for passing the array?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Code: Select all

$URLArray = base64_encode(serialize($Array)); // write
$Array = unserialize(base64_decode($_GET['Array'])); //read
There are 10 types of people in this world, those who understand binary and those who don't
Yourchild
Forum Newbie
Posts: 16
Joined: Mon Jul 30, 2007 3:04 pm

Post by Yourchild »

thanks a lot! that worked smoothly!! :o
Post Reply