HTML id attribute and arrays
| From: | Martin C | Date: | Fri, 17 Dec 2010 16:19:32 +0000 |
| Subject: | HTML id attribute and arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-310112@lists.php.net to get a copy of this message | ||
Hi,
PHP converts x[a]=b parameter of the HTTP request as an array named x with its item named a set to value b. So, it seems possible to have the following (X)HTML code:
<input type="text" name="x[a]" id="x[a]" value="b" />
Unfortunatelly, HTML specification does not allow neither "[" nor "]" inside the id attribute. Specifically:
* Must begin with a letter A-Z or a-z
* Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
* Values are case-sensitive
How should I follow the HTML specification while having the passed parameters automatically converted to arrays in PHP?
Thank you for any tips,
Martin