Using arrays in form element names July 27, 2009 1 Comment
Sometimes there is variable number of similar elements on a form. For example, phone numbers. To iterate all filled values on the server it will be nice to use arrays. And form element naming allow it:
<form method="post">
<input type="text" name="phone[0]" />
<input type="text" name="phone[1]" />
…
</form>
Using PHP it’s easy to iterate through those values now:
foreach ($_POST[‘phone’] as phone) [...]
My name is Alexander Kleshchevnikov. I have been working as a professinal web application developer since 2002. I believe in simple intelligence from server technologies to front-end development. Now I run my own web development consulting company in Ukraine. You can find