From: Roan Kattouw Date: Sat, 24 May 2008 21:54:57 +0000 (+0000) Subject: Add array support to wfArrayToCGI(): when receiving parameters in the form of &foo... X-Git-Tag: 1.31.0-rc.0~47397 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=a8cfb856c44d9eb6ac43be8c9bb975897bb8b4e8;p=lhc%2Fweb%2Fwiklou.git Add array support to wfArrayToCGI(): when receiving parameters in the form of &foo[]=bar&foo[]=baz, PHP automatically sets $_GET['foo'] = array(bar, baz); When feeding the original query back to wfArrayToCGI(), it used to choke on that. Now wfArrayToCGI() actually converts array('bar', 'baz'); back to the &foo[]=bar&foo[]=baz form. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a9bf015df4..3294c8f9b0 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -999,7 +999,13 @@ function wfArrayToCGI( $array1, $array2 = NULL ) if ( '' != $cgi ) { $cgi .= '&'; } - $cgi .= urlencode( $key ) . '=' . urlencode( $value ); + if(is_array($value)) + foreach($value as $v) + $cgi .= urlencode( $key . '[]' ) . '=' . + urlencode( $v ); + else + $cgi .= urlencode( $key ) . '=' . + urlencode( $value ); } } return $cgi;