I am trying to generate variable name dynamically in php for loop. I want call a function within for loop and want to pass iterated values. What I tried is:
for ($i=1, $j=1; $i<=16 ; $i++, $j++) {
$a='arrtreelevel_1';
$b='0';
$newname = $a.$j.$b;
echo $newname,"<br>";
echo $arrtreelevel_1[0];
$arrtreelevel_2.$i = profiledetails($newname);
}
My problem is '$newname' variable printing $arrtreelevel_1[0] as a text not taking the value, and $arrtreelevel_11[0] returns the actual value.
I tried with echo ${'arrtreelevel_1$i'} also which printing nothing. Assist me with any solution please.
Thanks in advance.