note 90438 modified in function.http-build-query by danbrown

From: Date: Wed, 22 Apr 2009 12:54:51 +0000
Subject: note 90438 modified in function.http-build-query by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153584@lists.php.net to get a copy of this message
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 ?> --was-- If You use php <5 You can use this. (It works fine with complex arrays.) 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 http://php.net/manual/en/function.http-build-query.php

« previous php.notes (#153584) next »