Step by step building up a dynamic (e-commerce) website
<?php function my_array($num1,$num2,$num3){ $total_num1=$num1[0]+$num2[0]+$num3[0]; $total_num2=$num1[1]+$num2[1]+$num3[1]; $total_num3=$num1[2]+$num2[2]+$num3[2]; $answer=array(); $answer[0]=$total_num1; $answer[1]=$total_num2; $answer[2]=$total_num3; return $answer; } $num1=array(5,1,2); $num2=array(2,3,5); $num3=array(11,3,7); $result=my_array($num1, $num2,$num3); echo "<ul>"; echo "<li>".$result[0]."</li><br/>"; echo "<li>".$result[1]."</li><br/>"; echo "<li>".$result[2]."</li><br/>"; echo "</ul>";?>
thanks for trying, but it's not the correct answer.
<?phpfunction create_list($arr){ echo "<ul>"; foreach ($arr as $item){ echo "<li>".$item."</li>"; } echo "</ul>";}$myArray = array(2, 5, 1, 7, 3);create_list($myArray);?>
<?php
ReplyDeletefunction my_array($num1,$num2,$num3){
$total_num1=$num1[0]+$num2[0]+$num3[0];
$total_num2=$num1[1]+$num2[1]+$num3[1];
$total_num3=$num1[2]+$num2[2]+$num3[2];
$answer=array();
$answer[0]=$total_num1;
$answer[1]=$total_num2;
$answer[2]=$total_num3;
return $answer;
}
$num1=array(5,1,2);
$num2=array(2,3,5);
$num3=array(11,3,7);
$result=my_array($num1, $num2,$num3);
echo "<ul>";
echo "<li>".$result[0]."</li><br/>";
echo "<li>".$result[1]."</li><br/>";
echo "<li>".$result[2]."</li><br/>";
echo "</ul>";
?>
thanks for trying, but it's not the correct answer.
ReplyDelete<?php
ReplyDeletefunction create_list($arr){
echo "<ul>";
foreach ($arr as $item){
echo "<li>".$item."</li>";
}
echo "</ul>";
}
$myArray = array(2, 5, 1, 7, 3);
create_list($myArray);
?>