Jump to content

*SOLVED* Is there a function that can take all the parameters of a URL?


HuggieBear

Recommended Posts

I want to put all of the parameters of URL into an array, no matter what they are called.  Is there a function for this?

So if my GET url is index.php?firstname=richard&nickname=huggie

I get an array created that would be equivalent to:

[code=php:0]$url = array('firstname' => "richard", 'nickname' => "Huggie");
[/code]

[size=8pt][color=red][b]Edit:[/b][/color][/size] Or even just the field names would be fine.  I'm currently investigating the HTTP extension

Regards
Huggie
Link to comment
Share on other sites

Use a foreach loop to loop through all variables in the url:
[code=php:0]$url = array();

foreach($_GET as $key => $value)
{
    $url[$key] = $value;
}[/code]


However the following is the same as above:
[code=php:0]$url = $_GET;[/code]


The $_GET variable is what gets the variables from the url. if you wnat to just get the variable names from thr URL use this:
[code=php:0]$url = array();

foreach($_GET as $key => $value)
{
    $url[] = $key;
}

echo "<pre>\n" . print_r($url, true) . '</pre>';[/code]
Link to comment
Share on other sites

[quote author=wildteen88 link=topic=108274.msg435418#msg435418 date=1158398898]
The $_GET variable is what gets the variables from the url. if you wnat to just get the variable names from thr URL use this:
[code=php:0]$url = array();

foreach($_GET as $key => $value)
{
    $url[] = $key;
}

echo "<pre>\n" . print_r($url, true) . '</pre>';[/code]
[/quote]

or simply $urlArr = array_keys($_GET);
Link to comment
Share on other sites

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.