Calculate the variable name for simpler variables and use that name to access the value of that variable. : Variables « Language Basics « PHP






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} ";
}
?>
  
  








Related examples in the same category

1.PHP Variable Examples
2.PHP Superglobal Arrays
3.PHP 5 variable functionality.
4.A properly set-up PHP variable
5.Automatic Type Conversion
6.Operating on variables
7.valid statements
8.Numbers
9.Numeric Data Types
10.Valid and invalid variable names