note 75944 added to function.http-parse-params
| From: | SiegfriedGevatterrainct at ubuntuwire dot com | Date: | Fri, 22 Jun 2007 19:37:27 +0000 |
| Subject: | note 75944 added to function.http-parse-params | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127893@lists.php.net to get a copy of this message | ||
<?PHP
/* This simple function gets the query out of a URL, splits it
* and puts it into an array.
*
* For example, "index.php?name=Myself&message=Hello" will
* become an array looking like this:
* array['name'] = 'Myself'
* array['message'] = 'Hello'
*/
function getParser($url) {
// Extract the query
$query = parse_url($url);
$query = $query['query'];
// Split it
$query = explode('&', $query);
// Get the elements and put them in an array
$gets = array();
foreach($query AS $element) {
list($name, $value) = explode('=', $element, 2);
$gets[$name] = $value;
}
// Return the array
return $gets;
}
// Example
$_GET = getParser($_SERVER['REQUEST_URI']);
// Let's look what it got
echo '<pre>';
print_r($_GET);
echo '</pre>';
?>
----
Server IP: 69.147.83.197
Probable Submitter: 77.209.5.150
----
Manual Page -- http://www.php.net/manual/en/function.http-parse-params.php
Edit -- https://master.php.net/note/edit/75944
Del: integrated -- https://master.php.net/note/delete/75944/integrated
Del: useless -- https://master.php.net/note/delete/75944/useless
Del: bad code -- https://master.php.net/note/delete/75944/bad+code
Del: spam -- https://master.php.net/note/delete/75944/spam
Del: non-english -- https://master.php.net/note/delete/75944/non-english
Del: in docs -- https://master.php.net/note/delete/75944/in+docs
Del: other reasons-- https://master.php.net/note/delete/75944
Reject -- https://master.php.net/note/reject/75944
Search -- https://master.php.net/manage/user-notes.php