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

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.