monkinetic weblog

Steve Ivy's Weblog - Since 1999 - XII Ed.

Form Handling in PHP

I found out a cool feature of PHP today. I'm sure that every other PHP hacker on the planet already knows this, but I didn't ;–).

If you have several form elements that all pertain to a single entity, you can write your HTML like this:

<input name="entity[property]" value="$val" />

and PHP will create an associative array in the $_GET data with the name entity and a key property with value $val. Nice!

P.S. I did find a pointer to this page on Variables from Outside PHP that sort-of explains it, but it doesn't really address the associative-array feature.

My name is Steve Ivy and I write about technology, the open web, social software, and general nerdity on monkinetic.com. You should follow me on Twitter or subscribe to this blog if you like what you're reading. I spend my days hacking Movable Type, python, Django, and various other efforts at Wallrazer. This is my personal site.