Hi guys,
I have a script where I recieve variable data from a script I dont have control over like so:
$var1 = 'value';
$var2 = 'value 2';
$var3 = 'value 3';
I also get a variable like $var_count which has the total number of variables that is sent to me total (in this case 3). They are all named in the same pattern (var1, var2, var3, etc)
The thing is I dont know how many I will get, I can get only up to $var2, or up to $var150;
I am trying to figure out a way to create a loop that will give me the value for each variable I recieve from the external script and output the values.
So lets say I get a total of 4 variables.
How can I make a loop that will give me those variable values:
I got this so far:
for($i=0; $i <=$var_count; $i++)
{
echo $var<WHAT THE HECK DO I PUT HERE TO GET THE VARIABLE NUMBER IN THE NAME>. '<br />';
}
As you can see, my problem is stated in the code. I tried doing: echo $var$i ... got an error, also echo $var . $i ... which gives the value of $var AND $i together as it should.
I jsut want to figure out how to call the variable $var<number in series>