Solve array challange on php
Code is :
$array = array(1,2,3,5,8,13,21,34,55);
$sum = 0;
echo "i = array(i) = array(array(i))
";
for( $i=0;$i<5 br="" i=""> echo $i. " = ".$array[$i] . " = " .$array[$array[$i]]."
";
$sum += $array[$array[$i]];
}
echo $sum;5>
Output :
i = array(i) = array(array(i))
0 = 1 = 2
1 = 2 = 3
2 = 3 = 5
3 = 5 = 13
4 = 8 = 55
78
$array = array(1,2,3,5,8,13,21,34,55);
$sum = 0;
echo "i = array(i) = array(array(i))
";
for( $i=0;$i<5 br="" i=""> echo $i. " = ".$array[$i] . " = " .$array[$array[$i]]."
";
$sum += $array[$array[$i]];
}
echo $sum;5>
Output :
i = array(i) = array(array(i))
0 = 1 = 2
1 = 2 = 3
2 = 3 = 5
3 = 5 = 13
4 = 8 = 55
78
Comments
Post a Comment