NYCPHP Meetup

NYPHP.org

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

Dan Cech dcech at phpwerx.net
Wed Aug 4 15:32:55 EDT 2004


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



More information about the talk mailing list