Jump to content

Need help on variables and cycles


NoobNewbie

Recommended Posts

Hi! ;D

 

I'm new to php, and I was wondering how can we call variables thorugh a for cycle, for example. Allow me to explain:


$var1 = 'Hello';
$var2 = 'Hello again';

for($a=1;$a<=2;++$a){
    echo $var.$a;
}

 

I thought that it would echo the two variables, but it's echoing 12 instead. I believe its some syntax error, because in other languages we can do that. So, how can we do that?

Link to comment
https://forums.phpfreaks.com/topic/58103-need-help-on-variables-and-cycles/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.