note 51162 added to function.http-build-query

From: Date: Tue, 22 Mar 2005 13:26:48 +0000
Subject: note 51162 added to function.http-build-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-86777@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.http-build-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51162 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51162&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51162&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51162&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51162&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51162&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51162&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86777) next »