+ 2

Hi, Why the answer is 5 of the code below?

https://code.sololearn.com/wMY5z0Vjjk60/?ref=app

26th Jul 2019, 1:55 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
3 Respuestas
+ 9
$i value will be vary 1 to 10 as use of the loop ${"a"."$i"} will make the number as $a1 to $a10 and you are priting the value of $a1+$a10-$a6 so this value is came by this condition ${"a"."$i"}=11-$i; For $i = 1 $a1 =11-1 = 10 $a10 = 11-10 = 1 $a6 = 11-6 = 5 You are printing this value echo $a1+$a10-$a6; So output will be 10+1-5 = 11-5 = 6 So output is 6
26th Jul 2019, 2:44 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
I found if we change $a6, the result is 6,
26th Jul 2019, 2:26 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 2
Thank You very much, STEASY!
27th Jul 2019, 5:10 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar