0
What is the function of dot between the ${"a"."$i"}?
for ($i=1; $i<=10; $i++) ${"a"."$i"} = 11- $i; // i started to confuse at this line echo $a1 + $a10 - $a5; // The answer is 5 but couldn't figure why. I need an explanation, please.
1 Answer
+ 12
. is the string concatenation operator.
${"a"."$i"} = $a1 when i = 1
So, $a1 = 11 - $i = 10
So, $a1, $a2, ..., $a10 => 10, 9, ..., 1
$a1 + $a10 - $a5 = 10 + 1 - 6 = 5.