note 57280 deleted from function.http-build-query by hholzgra

From: Date: Thu, 02 Aug 2012 13:36:02 +0000
Subject: note 57280 deleted from function.http-build-query by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189768@lists.php.net to get a copy of this message
Note Submitter: vlad_mustafin at ukr dot net ---- My example of this function for PHP versions < PHP5 without any regular expressions, just cycles, recursion and standard functions. It can work with complex arrays or objects or both combined. <?php if(!function_exists('http_build_query')) { function http_build_query( $formdata, $numeric_prefix = null, $key = null ) { $res = array(); foreach ((array)$formdata as $k=>$v) { $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k); if ($key) { $tmp_key = $key.'['.$tmp_key.']'; } if ( is_array($v) || is_object($v) ) { $res[] = http_build_query($v, null, $tmp_key); } else { $res[] = $tmp_key."=".urlencode($v); } } return implode("&", $res); } } ?>

« previous php.notes (#189768) next »