Jump to content

Add "i" from for loop to the end of a variable??


VanMeter

Recommended Posts

Is there a way to call a specific variable by adding the i from a for loop? For example:

 

I have variables Branch0 Branch1 Branch2 being submitted from a form to be processed.

 

I am using a for loop to write the values of these variables.

 

I tried this but it doesn't work:

for ( $i = 0; $i < 15; $i++ ){
	echo $Branch$i;
}

I also tried this:

for ( $i = 0; $i < 15; $i++ ){
	echo $Branch+$i;
}

 

So is there any way to call a variable using the i to specify which variable...?

 

I know I could use an array but it doesn't work for this application  ???

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.