COMPUTER LEARNING CENTER
WWW.HUUKHANG.COM
<html>
<head>
<title>Array</title>
</head>
<body>
<h4>Mang mot chieu</h4>
<?php
$i=0;
$myarr=array(1,2,3,4,5,6,7);
$arr=array();
$arrs=array(10);
$arr[0]=10;$arr[1]=11;$arr[2]=12;$arr[3]=13;
for($i=0;$i<sizeof($arr);$i++)
{
echo $arr[$i]." ";
}
echo "<br>";
echo "Gia tri lon nhat ".max($arr)."<br>";
echo "Gia tri nho nhat ".min($arr)."<br>" ;
echo "Gia tri trung binh ".array_sum($arr) / sizeof($arr)."<br>" ;
echo "<br>";
for($i=0;$i<=10;$i++)
{
$arrs[$i]=10+$i;
}
for($i=0;$i<=10;$i++)
{
echo $arrs[$i]." ";
}
echo "<br>";
echo "Gia tri lon nhat ".max($arrs)."<br>";
echo "Gia tri nho nhat ".min($arrs)."<br>" ;
echo "Gia tri trung binh ".array_sum($arrs) / sizeof($arrs)."<br>" ;
?>
</body>
</html>
Keát quaû trình baøy nhö hình 7-7 khi trieäu goïi trang arrayone.php.
Giaùo vieân: Phaïm Höõu Khang