Emperio Posted March 27, 2010 Share Posted March 27, 2010 Hi i got a question about a variable I try to do this while($i<=$userstats3[lineupgrade]) { $line$i='test'; print "'$line$i'"; $i++; } But its not working I want to give the variable of 'test' a name+$i so when i = 2 it must be the line2.. But this shows error can someone tell me how to do it right? Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/ Share on other sites More sharing options...
oni-kun Posted March 27, 2010 Share Posted March 27, 2010 ${"line$i"}; Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/#findComment-1032825 Share on other sites More sharing options...
Emperio Posted March 28, 2010 Author Share Posted March 28, 2010 ${"line$i"}; It working great but if i want to use it in a if i use it like this: if{${"line$i"}==2} { something happens; } I get this error Parse error: syntax error, unexpected T_IS_EQUAL, expecting '}' in /home/a6767130/public_html/setline1.php on line 27 Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/#findComment-1033152 Share on other sites More sharing options...
andrewgauger Posted March 28, 2010 Share Posted March 28, 2010 if (${"line$i"}==2) ?? Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/#findComment-1033270 Share on other sites More sharing options...
Emperio Posted March 29, 2010 Author Share Posted March 29, 2010 Oh shit damm how stupid, sorry Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/#findComment-1033354 Share on other sites More sharing options...
andrewgauger Posted March 29, 2010 Share Posted March 29, 2010 lol Link to comment https://forums.phpfreaks.com/topic/196733-help-with-a-variable-question/#findComment-1033362 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.