Can some one help me to understand this PHP question please? $result = 0; and $i = 0; how can their addition be 10??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can some one help me to understand this PHP question please? $result = 0; and $i = 0; how can their addition be 10???

function func($arg) { $result = 0; for($i=0; $i<$arg; $i++) { $result = $result + $i; } return $result; } echo func(5);

4th Nov 2016, 3:56 PM
Haikal Jama Shaywal
1 Answer
0
1+2+3+4=10 The for loop add the numbers http://www.w3schools.com/php/php_looping_for.asp
8th Nov 2016, 6:34 AM
рооройрпЛроЬрпНроХрпБрооро╛ро░рпН рокро┤ройро┐роЪрпНроЪро╛рооро┐
рооройрпЛроЬрпНроХрпБрооро╛ро░рпН рокро┤ройро┐роЪрпНроЪро╛рооро┐ - avatar