note 55085 deleted from function.is-array by danbrown

From: Date: Sat, 27 Dec 2008 16:50:20 +0000
Subject: note 55085 deleted from function.is-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148567@lists.php.net to get a copy of this message
Note Submitter: doker0 at wp dot pl ---- This should hack the hack to accept tables NOTICE! Works only for 1-dim arrays. if (!function_exists('http_build_query')) { function http_build_query($formdata, $numeric_prefix = "") { $arr = array(); foreach ($formdata as $key => $val) $arr[] = is_array($val) ? http_build_query($val,$key) : ( $numeric_prefix !='' ? (urlencode($numeric_prefix) . '[' . urlencode($key) . ']') : urlencode($key)) . "=".urlencode($val) ; return implode($arr, "&"); } } for query '?a[0]=w&b=ggg&a[1]=x&a[2]=y&a[3]=z' var_export($_GET); shows array ( 'a' => array ( 0 => 'w', 1 => 'x', 2 => 'y', 3 => 'z', ), 'b' => 'ggg', ) and echo (http_build_query($_GET)); shows a[0]=w&a[1]=x&a[2]=y&a[3]=z&b=ggg

« previous php.notes (#148567) next »