NYCPHP Meetup

NYPHP.org

[nycphp-talk] Jamming multi-dimensional arrays in a Query stri ng.

Chris Bielanski Cbielanski at inta.org
Wed Aug 4 15:39:17 EDT 2004


Since I'm using PHP4, I don't have the oh-so-snazzy build_query_string(),
but for academia's sake, what does *it* do when handed a multi-dim array?


Thanks,
Chris Bielanski
Web Programmer, 
International Trademark Association,
1133 Avenue of the Americas, 33rd Floor
New York, NY 10036
+1 (212) 642-1745, f: +1 (212) 768-7796
mailto:cbielanski at inta.org, www.inta.org  
INTA -- 125 Years of Excellence



> -----Original Message-----
> From: Dan Cech [mailto:dcech at phpwerx.net]
> Sent: Wednesday, August 04, 2004 3:33 PM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] Jamming multi-dimensional arrays in a Query
> string.
> 
> 
> Chris Bielanski wrote:
> 
> > Anyone have a method for getting a multidimensional array 
> passed on the
> > query string using GET?
> 
> You *can* do it, just use the xxx[][] syntax, like:
> 
> http://www.example.com/index.php?test[1][hello]=tiger&test[1][
test]=testing&test[2][]=a&test[2][]=test

would become:

$_GET['test'] = array (
	'1' => array (
		'hello' => 'tiger',
		'test' => 'testing'
	),
	'2' => array (
		'a',
		'test'
	)
);

Technically the [] syntax shouldn't be used, but it in the real world it 
works and can save a lot of headaches.

Dan
_______________________________________________
New York PHP Talk
Supporting AMP Technology (Apache/MySQL/PHP)
http://lists.nyphp.org/mailman/listinfo/talk
http://www.newyorkphp.org



More information about the talk mailing list