DamienRoche Posted September 10, 2008 Share Posted September 10, 2008 I have one last problem, and I swear I won't spam the board. Very sorry I didn't put this in a reply, but I was so excited I sorted something out I just pressed the 'topic solved' link. The loop: $loop = 1; $limit = 3; $Y = 0; $N = 0; while ($loop <= $limit){ $fb = "\$e".$loop."fname"; $sb = "\$e".$loop."sname"; $pb = "\$e".$loop."passport"; $cb = "\$e".$loop."check"; echo "fb:$fb<br>sb:$sb<br>pb:$pb<br>cb:$cb<br>"; if($cb!=""){ if($fb!="" && $sb!="" && $pb!=""){ $Y = $Y + 1;}else{$N = $N + 1;} } $loop = $loop +1; } Output for one loop of the echo: fb:$e1fname sb:$e1sname pb:$e1passport cb:$e1check The variables within the variables I am creating ($fb,$sb etc.) are not acting as variables. I can see when I echo them that they are outputting text and not functioning php. Do you have any idea why? How do I construct these variables so when I call the variable that constructed them, they call the variable constructed and not a bunch of text...BREATHE... Last question. Any help much appreciated. Link to comment https://forums.phpfreaks.com/topic/123572-will-not-spam-board-last-question-producing-variables-from-variables/ Share on other sites More sharing options...
JasonLewis Posted September 10, 2008 Share Posted September 10, 2008 Remove the \ in front of the $e or you can try using eval() on the string. Link to comment https://forums.phpfreaks.com/topic/123572-will-not-spam-board-last-question-producing-variables-from-variables/#findComment-638175 Share on other sites More sharing options...
DamienRoche Posted September 10, 2008 Author Share Posted September 10, 2008 Thanks ProjectFear!- you have been a saint tonight. Sadly, removing the \ didn't work because then the 'e' turned into a variable itself. Evals would of seeded even more questions. I did, however, find a solution so will post here just in case. $loop = 1; $fb = ${"e".$loop."fname"}; ///this makes the variable $fb return a new variable $e1fname Thanks again PF for all your help. Link to comment https://forums.phpfreaks.com/topic/123572-will-not-spam-board-last-question-producing-variables-from-variables/#findComment-638176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.