I am having trouble dynamically naming my PHP variables when doing a foreach loop. Here is my code:
$count = count($_POST['member']);
for ($i = 0; $i < $count; $i++) {
$fname = $_POST['member'][$i]['fname'];
$lname = $_POST['member'][$i]['lname'];
}
How would I append the number contained in $i
to $fname
& $lname
so that $fname
& $lname
become $fname1
& $lname_2
and so on? Or is there a better way of doing this? Nothing I have tried works.