note 90438 deleted from function.http-build-query by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 13:38:08 +0000 |
| Subject: | note 90438 deleted from function.http-build-query by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189779@lists.php.net to get a copy of this message | ||
Note Submitter: Marco K. (Germany)
----
If You use php <5 You can use this. (It works fine with complex arrays.)
<?php
if (!function_exists('http_build_query')) {
function http_build_query($data, $prefix='', $sep='', $key='') {
$ret = array();
foreach ((array)$data as $k => $v) {
if (is_int($k) && $prefix != null) {
$k = urlencode($prefix . $k);
}
if ((!empty($key)) || ($key === 0)) $k = $key.'['.urlencode($k).']';
if (is_array($v) || is_object($v)) {
array_push($ret, http_build_query($v, '', $sep, $k));
} else {
array_push($ret, $k.'='.urlencode($v));
}
}
if (empty($sep)) $sep = ini_get('arg_separator.output');
return implode($sep, $ret);
}// http_build_query
}//if
?>