note 99397 deleted from function.http-build-query by danbrown
| From: | danbrown@php.net | Date: | Tue, 17 Aug 2010 16:38:23 +0000 |
| Subject: | note 99397 deleted from function.http-build-query by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-171778@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Further to valdikss at gmail dot com, here's a version that also honours the original signature
<?php
function http_build_query_alt(array $array, $numericPrefix = '', $argSeparator = null,
$deep = false) {
if ($argSeparator === null) $argSeparator = ini_get('arg_separator.output');
$result = array();
foreach ($array as $key => $value) {
if ($deep) $key = $numericPrefix . '[]';
elseif (is_int($key)) $key = $numericPrefix . $key;
if (is_array($value) || is_object($value)) {
$result[] = http_build_query_alt($value, $key, $argSeparator, true);
continue;
}
$result[] = urlencode($key) . '=' . urlencode($value);
}
return implode($argSeparator, $result);
}
?>