Mega Code Archive

 
Categories / Php / Language Basics
 

Calculate the variable name for simpler variables and use that name to access the value of that variable

<?php $a0 = 'This'; $a1 = 'is'; $a2 = 'a'; $a3 = 'test'; for ($i = 0; $i < 4; $i++) {   $var = "a$i";   echo "${$var} "; } ?>