RsD0p9BK
8/4/2014 - 12:33 PM

declare_var.php

// Declare variables in loop
// http://stackoverflow.com/questions/9491151/declare-variables-on-the-fly-using-for-loop

for ($i = 1; $i <= 5; $i++) 
{
  ${"val".$i} = "this is value " . $i;
}    

echo "$val1<br />$val2<br />$val3<br />$val4<br />$val5";