note 102212 deleted from function.parse-str by nikic
| From: | nikic@php.net | Date: | Thu, 23 Aug 2012 11:16:54 +0000 |
| Subject: | note 102212 deleted from function.parse-str by nikic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190184@lists.php.net to get a copy of this message | ||
Note Submitter: eclipsehtd at hotmail dot com
----
I wrote an array to string function that works recursively and works with an n-dimensional array
turning it into a parsable string for parse_str.
<?php
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;
}
?>