note 102212 added to function.parse-str
| From: | eclipsehtd at hotmail dot com | Date: | Thu, 03 Feb 2011 00:54:02 +0000 |
| Subject: | note 102212 added to function.parse-str | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176607@lists.php.net to get a copy of this message | ||
I had a problem with the above array to string function, so I wrote one that works recursively and
works with an n-dimensional array turning it into a parsable string for parse_str.
function queryString($params, $name=null) {
$ret = "";
foreach($params as $key=>$val) {
if(is_array($val)) {
if($name==null) $ret .= queryString($val, $key);
else $ret .= queryString($val, $name."[$key]");
} else {
if($name!=null)
$ret.=$name."[$key]"."=$val&";
else $ret.= "$key=$val&";
}
}
return $ret;
}
----
Server IP: 69.147.83.197
Probable Submitter: 216.94.9.201
----
Manual Page -- http://www.php.net/manual/en/function.parse-str.php
Edit -- https://master.php.net/note/edit/102212
Del: integrated -- https://master.php.net/note/delete/102212/integrated
Del: useless -- https://master.php.net/note/delete/102212/useless
Del: bad code -- https://master.php.net/note/delete/102212/bad+code
Del: spam -- https://master.php.net/note/delete/102212/spam
Del: non-english -- https://master.php.net/note/delete/102212/non-english
Del: in docs -- https://master.php.net/note/delete/102212/in+docs
Del: other reasons-- https://master.php.net/note/delete/102212
Reject -- https://master.php.net/note/reject/102212
Search -- https://master.php.net/manage/user-notes.php