HuggieBear Posted September 16, 2006 Share Posted September 16, 2006 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=huggieI 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 extensionRegardsHuggie Link to comment https://forums.phpfreaks.com/topic/20959-solved-is-there-a-function-that-can-take-all-the-parameters-of-a-url/ Share on other sites More sharing options...
wildteen88 Posted September 16, 2006 Share Posted September 16, 2006 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 https://forums.phpfreaks.com/topic/20959-solved-is-there-a-function-that-can-take-all-the-parameters-of-a-url/#findComment-92922 Share on other sites More sharing options...
ronverdonk Posted September 16, 2006 Share Posted September 16, 2006 Something liike the following:[code]$myarray = array(); foreach($_POST as $key => $val) $myarray[$key] = $val;[/code]Ronald 8) Link to comment https://forums.phpfreaks.com/topic/20959-solved-is-there-a-function-that-can-take-all-the-parameters-of-a-url/#findComment-92923 Share on other sites More sharing options...
HuggieBear Posted September 16, 2006 Author Share Posted September 16, 2006 It's so logical, I don't know why I didn't realise that in the first place.Thanks Wildteen.Huggie Link to comment https://forums.phpfreaks.com/topic/20959-solved-is-there-a-function-that-can-take-all-the-parameters-of-a-url/#findComment-92924 Share on other sites More sharing options...
448191 Posted September 16, 2006 Share Posted September 16, 2006 [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 https://forums.phpfreaks.com/topic/20959-solved-is-there-a-function-that-can-take-all-the-parameters-of-a-url/#findComment-92991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.