Jump to content

Archived

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

Infected-Waffle

multiple items in 1 $_get

Recommended Posts

Is there a way to store multiple variables in 1 $_GET['']?

edit: what I mean is, is there a way to make something like:
whatever.php/something.php?d0=var1, var2

kind of like an array in the url

Share this post


Link to post
Share on other sites
You can pass arrays, yes. Like if you have a bunch of checkboxes, just name them like this: mycheckboxes[]

Then in your processing:

[code]foreach($_GET['mycheckboxes'] as $key)
   echo "$key<br>";[/code]

Share this post


Link to post
Share on other sites
It's not check box's. It's like if you click a link it adds it to the url var and keeps it until you end the game (whihc is what this is for.) I need a way to force link colors to change during one game session, so I decided to store the used options in the url and call them from there and add them each time you visit a page.

[a href=\"http://www.infected-designs.com/jeopardy/\" target=\"_blank\"]http://www.infected-designs.com/jeopardy/[/a]

it's for that, you'll understand when you look at one of the boards.

edit:

here's the source if you need it...
[a href=\"http://www.infected-designs.com/jeopardy/source/\" target=\"_blank\"]http://www.infected-designs.com/jeopardy/source/[/a]

Share this post


Link to post
Share on other sites
Yes you can place an array within an array in a ur. Something like this:
[code]<?php

if(isset($_GET['say']))
{
    echo '<pre>' . print_r($_GET['say'], true) . '</pre>';
}

?>
<a href="?say['hello']=hello&say['world']=world">Set the array in the url!</a>[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=372387:date=May 8 2006, 03:47 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 8 2006, 03:47 PM) [snapback]372387[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Yes you can place an array within an array in a ur. Something like this:
[code]<?php

if(isset($_GET['say']))
{
    echo '<pre>' . print_r($_GET['say'], true) . '</pre>';
}

?>
<a href="?say['hello']=hello&say['world']=world">Set the array in the url!</a>[/code]
[/quote]
I'm confused. Could you please explain more?

Share this post


Link to post
Share on other sites
Basically say['hello'] is an array

say is the primary array ($_GET['say']) to get the bits in the [] after say you use $_GET['say']['hello'];

You are just setting an array within the url.

The print_r function in the code supplied shows the contents of the $_GET['say'] array.

I haveing arrays within a URL isn't most pleasent thing to see as can become confusing.

Share this post


Link to post
Share on other sites

×

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.