note 43097 added to function.http-build-query
| From: | brainstar at gmail dot com | Date: | Wed, 09 Jun 2004 16:35:48 +0000 |
| Subject: | note 43097 added to function.http-build-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70418@lists.php.net to get a copy of this message | ||
You can also just use this "userland" function to do the same thing.
<?
//http_build_query it is not supported until PHP 5
function my_http_build_query ($getarray) {
if (!is_array($getarray))
return "";
//go throuh each of the base params
$getquery = "";
foreach ($getarray as $name => $value) {
//call the recurse to go through each array within array...etc
my_http_build_query_recurse($getquery, $name, $value);
}
return $getquery;
}
function my_http_build_query_recurse (&$getquery, $nameprefix, $input) {
//check if this input is an array
if (is_array($input)) {
//then we need to interate it
//and add values for each of its elements
//build on the nameprefix so we can do any level of nested arrays
foreach ($input as $index => $value) {
my_http_build_query_recurse($getquery, $nameprefix . "[" . $index . "]",
$value);
}
} else {
//otherwise just output this param
if (isset($input)) {
if ($getquery != "")
$getquery .= "&";
$getquery .= $nameprefix . "=" . $input;
}
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.http-build-query.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43097
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43097&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43097&report=yes
Search -- http://master.php.net/manage/user-notes.php