Laporan Praktikum 5
Praktikum 5.1 Array Satu Dimensi
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">
<head>
<tittle>Praktikum 4.Perulangan</tittle><br>
<meta http-equiv="content-type" content="text/html; charsct=utf-8" />
<meta name="generator" content="Geany 0.20" />
</head>
<body>
<?php
//membuat array
$mahasiswa = array("Toni","Joko","Agam","Tina","Lia","Yana");
$ipk = array(3.23,2.89,4.00,3.12,2.67,2.22);
$i = 0;
//mengakses array
echo "<table border = 1>";
echo "<tr>";
echo "<td>No</td>";
echo "<td>Nama</td>";
echo "<td>ipk</td>";
echo "</tr>";
while ($nama = each ($mahasiswa)){
echo "<tr>";
$no = $nama[0] + 1;
echo "<td>$no</td>";
echo "<td>$nama[1]</td>";
echo "<td>$ipk[$i]</td>";
echo "</tr>";
$i++;
}
echo "</table>";
?>
</body>
</html>
"http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">
<head>
<tittle>Praktikum 4.Perulangan</tittle><br>
<meta http-equiv="content-type" content="text/html; charsct=utf-8" />
<meta name="generator" content="Geany 0.20" />
</head>
<body>
<?php
//membuat array
$mahasiswa = array("Toni","Joko","Agam","Tina","Lia","Yana");
$ipk = array(3.23,2.89,4.00,3.12,2.67,2.22);
$i = 0;
//mengakses array
echo "<table border = 1>";
echo "<tr>";
echo "<td>No</td>";
echo "<td>Nama</td>";
echo "<td>ipk</td>";
echo "</tr>";
while ($nama = each ($mahasiswa)){
echo "<tr>";
$no = $nama[0] + 1;
echo "<td>$no</td>";
echo "<td>$nama[1]</td>";
echo "<td>$ipk[$i]</td>";
echo "</tr>";
$i++;
}
echo "</table>";
?>
</body>
</html>
Praktikum 5.2 Array Multi-Dimensi
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">
<head>
<tittle>Praktikum 5 Array</tittle><br>
<meta http-equiv="content-type" content="text/html; charsct=utf-8" />
<meta name="generator" content="Geany 0.20" />
</head>
<body>
<?php
//membuat array
$mahasiswa = array (
array(
"nama" =>"Toni",
"nim" => "123456789",
"IPK" => 2.79
),
array (
"nama" => "Joko",
"nim" => "234567890",
"IPK" => 2.67
),
array (
"nama" => "Tina",
"nim" => "4567890145",
"IPK" => 2.34
),
array (
"nama" => "Lia",
"nim" => "6789043256",
"IPK" => 3.12
),
array (
"nama" => "Agam",
"nim" => "67452253436",
"IPK" => 4.00
),
array (
"nama" => "Yanna",
"nim" => "345562327844",
"IPK" => 3.56
),
);
echo "<table border=1>";
echo "<tr>";
echo "<td>Nama</td>";
echo "<td>N I M</td>";
echo "<td>IPK</td>";
foreach ($mahasiswa as $nama){
echo "<tr>";
foreach ($nama as $key =>$value){
echo "<td>$value</td>";
}
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
"http://www.w3.org/TR/xhtml/DTD/xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="on" lang="on">
<head>
<tittle>Praktikum 5 Array</tittle><br>
<meta http-equiv="content-type" content="text/html; charsct=utf-8" />
<meta name="generator" content="Geany 0.20" />
</head>
<body>
<?php
//membuat array
$mahasiswa = array (
array(
"nama" =>"Toni",
"nim" => "123456789",
"IPK" => 2.79
),
array (
"nama" => "Joko",
"nim" => "234567890",
"IPK" => 2.67
),
array (
"nama" => "Tina",
"nim" => "4567890145",
"IPK" => 2.34
),
array (
"nama" => "Lia",
"nim" => "6789043256",
"IPK" => 3.12
),
array (
"nama" => "Agam",
"nim" => "67452253436",
"IPK" => 4.00
),
array (
"nama" => "Yanna",
"nim" => "345562327844",
"IPK" => 3.56
),
);
echo "<table border=1>";
echo "<tr>";
echo "<td>Nama</td>";
echo "<td>N I M</td>";
echo "<td>IPK</td>";
foreach ($mahasiswa as $nama){
echo "<tr>";
foreach ($nama as $key =>$value){
echo "<td>$value</td>";
}
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
EmoticonEmoticon