Forum Moderators: coopster

Message Too Old, No Replies

HTML Form Array processing.

Multiple text boxes in an array...

         

Alexia_E

11:03 pm on Jan 22, 2006 (gmt 0)



What I'm trying to do is figure out if I can use a text input in an array that PHP can process. This information is applicant information that is added to a group registration. There is no set number of applicants, so the script is told how many times to output the same input text boxes.


----
P01: <input type=\"text\" name=\"firstname[]\"/>
P02: <input type=\"text\" name=\"firstname[]\"/>
...etc...
----

This is code that processes it. A bit inefficient, I want to make this work out better since I'm calling "current" just to use a loop to do "next". I would love to just loop through the array using the index numbers in one loop.


$num = $_POST[numapplicants];
echo current($_POST[firstname]);
for ($i=0; $i<$num; $i++) {
echo next($_POST[firstname]);
}

coopster

2:26 pm on Jan 23, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Alexia_E.

There are a number of ways to process each element in an array, one of which is array_walk() [php.net]. Would that work for you?