Question : PHP String Concatenation Help

I have an HTML form with many fields - all coded like this:

<input name="firstname[1]" type="text" size="15">

My PHP script will loop through all fields (firstname[1], firstname[2], firstname[3], etc).  Problem is I can't figure out how to combine the fields and numeral value in the code.  I tried this:

$val_firstname = $_POST[firstname.'['.$i.']']; 

but that did not work.  What's the proper way?

Answer : PHP String Concatenation Help

You have to load it into an array first i think

The $_POST['firstname'] contains an array

so you can also loop through the array


   $myString = '';
   foreach($_POST['firstname'] as $myName){
      $myString .= $myName . ", ";
      echo $myString;


or assign it to an array and then reference the index.

$myArray = $_POST['firstname'];
echo $myArray[3];
Random Solutions  
programming4us programming4us