note 55086 added to function.parse-url

From: Date: Mon, 25 Jul 2005 11:01:24 +0000
Subject: note 55086 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-92408@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55086 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55086&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55086&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92408) next »