I would like to create a loop that names the variables based on i so it should be $l_name0, $lname1, etc. This is what I tried to do, however it just looped forever and did not work.
for ($i=0; $i<=2; $i++) {
$L_NAME.$i='name'.$i;
$L_AMT.$i='amt'.$i;
$L_QTY.$i='qty'.$i;
echo $L_NAME.$i;
}
Any ideas how I can do this?
Here is what you did wrong
for ($i=0; $i<=2; $i++) {
${'L_NAME'.$i} = 'name'.$i;
${'L_AMT'.$i} = 'amt'.$i;
${'L_QTY'.$i} = 'qty'.$i;
echo $L_NAME.$i;
}