note 51162 deleted from function.http-build-query by nlopess
| From: | nlopess@php.net | Date: | Tue, 22 Mar 2005 15:37:52 +0000 |
| Subject: | note 51162 deleted from function.http-build-query by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-86791@lists.php.net to get a copy of this message | ||
Note Submitter: ulderico at maber dot com dot br
Reason: useless
----
Hey Guys! You've stolen my idea! I'd like to have the credits!
And my function "implode_r" does pretty much the same thing!
Come on! I've made it MUCH SOONER than PHP 5...
I posted this comment:
ulderico at maber dot com dot br
07-Oct-2002 02:39
'Implode' does not implodes recursively... It might quite useful implode recursively when
you get a many Arrays values with keys that replaces themselves as:
http://server/file.php?arg[1]=123&arg[2]=312&arg[3]=543&arg[2]=abc
If you build this URL progressively it would a great a idea that the newest value indeed took the
place of any older ones, thus:
http://server/file.php?arg[1]=123&arg[3]=543&arg[2]=abc
would be a better option;
If one uses $_SERVER['REQUEST_URI'], this sanitation would not happen, the URL string
would be greater and greater everytime.
With implode_r (see below) it becomes easier to build a "sanitised" URL, the one that less
likely will overflow the browser.
$URL = $_SERVER['PHP_SELF'];
$tmp = implode_r("&", $_REQUEST); /* So as to allow to get ANY VALUE (G/P) from the
Browser... */
$URL .= "?".$tmp;
/* implode_r */
function implode_r($glue, $array, $array_name = NULL){
while(list($key,$value) = @each($array))
if(is_array($value))
$return[] = implode_r($glue, $value, (string) $key);
else
if($array_name != NULL)
$return[] = $array_name."[".(string)
$key."]=".$value;
else
$return[] = $key."=".$value;
return(implode($glue, $return));
}
sorry I couldn't format the code.