|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-11 12:35 UTC] derick@php.net
[2004-03-11 12:51 UTC] marwan at marvonline dot org
[2004-03-11 13:06 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 30 04:00:01 2025 UTC |
Description: ------------ PHP registers HTML variables that look like arrays as array variables, which is pretty convenient for packaging form variables. I'm building a form generator that utilizes this feature a lot. It uses it something like this: for ($i=0; $i<count($data['ID']); $i++) { echo "<input type=\"hidden\" name=\"data[ID][$i]\" value=\"{$data['ID'][$i]}\"> " ."<input type=\"text\" name=\"data[Name][$i]\" value=\"{$data['Name'][$i]\"><br>\n"; } The (slightly) annoying thing about this is that urlencoding the variable names replaces the '[' and ']' with three letter codes. If the arrays are large (as they typically are) this bloats the POST request quite a lot. If PHP would consider the '.' as an array operator when registering GET and POST variables, it would improve matters. The '.' is urlencoded as a '.' with no charcter inflation. Further, it would only require one operator instead of two ([ and ]). The code would then look like: for ($i=0; $i<count($data['ID']); $i++) { echo "<input type=\"hidden\" name=\"data.ID.$i\" value=\"{$data['ID'][$i]}\"> " ."<input type=\"text\" name=\"data.Name.$i\" value=\"{$data['Name'][$i]\"><br>\n"; } Since PHP forbids using the '.' in variable names anyway, this shouldn't affect much code. To be safe, an INI option could be made to switch this behaviour on and off. As far as I can tell, the only function that would need to change would be php_register_variable_ex in main/php_variables.c I would be quite willing to re-code the function and hand it to someone who has CVS access.