I'm a newbie when it comes to PHP, so I'm sorry if this is too simple and obvious.
I have a webform that users can add input fields to dynamically. When the user clicks submit all the input fields are saved into an array. When I use the print_r command I get an array that looks like this:
Array
(
[1] => Array ( [tc] => 00:10 [feedback] => good )
[2] => Array ( [tc] => 00:20 [feedback] => bad )
[3] => Array ( [tc] => 00:21 [feedback] => Bigger text )
)
The code I use to pull the data into the array is:
if (!empty($_POST)) { //The values have been posted
$elements = array();
foreach ($_POST as $key => $val) { //For every posted values
$frags = explode("_", $key); //we separate the attribute name from the number
$id = $frags[1]; //That is the id
$attr = $frags[0]; //And that is the attribute name
if (!empty($val)) {
//We then store the value of this attribute for this element.
$elements[$id][$attr] = htmlentities($val);
}
}
}
The way I would like to display the data is like this:
01: 00:10 - good<br />
02: 00:20 - bad<br />
03: 00:21 - Bigger text<br />
The form I am trying to make can be found at http://ridefreemedia.com.au/test
<input name="id[]" ... />rather than<input name="id_key" ... />