Disusun Oleh:
Nama: Toba Jordi Naibaho
NIM: 190411100115
Kelas: PAW B
Dosen Pengampu:
Nama: Devie Rosa Anamisa, S.Kom., M.Kom.
NIP: 19841104 200812 2 003
Asisten Praktikum:
Nama: Dimas Dliyaur Rahman
NIM: 210411100080
function tambah() {
global $fruits;
array_push($fruits,"Banana","Mango","Strawberry","Pine
apple","kiwi");
$arrlength = count($fruits);
for($x = 0; $x < $arrlength; $x++) {
echo $fruits[$x] . " => $x"; echo
"<br>";
}
echo "<hr>";
}
function kurang(){
global $fruits;
// Hapus element
unset($fruits[3]);
// pengindeks an ulang
$fruits = array_values($fruits);
// Menghitung ulang panjang array setelah pengindeksan
ulang
$arrlength = count($fruits);
function databaru() {
$vegies = array ("Wortel","Bayam","Kangkung");
$arrlength = count($vegies);
$arrlength = count($fruits);
function hapus() {
global $height;
unset($height["Adi"]);
echo "Indeks terakhir setelah menghapus data Adi adalah "
. array_key_last($height) . " tinggi " . end($height);
echo "<br>";
echo "<hr>";
}
function weight() {
$height["Adi"] = "70";
$height["Ridwan"] = "65";
$height["Zainal"] = "90";
Lima_Data_Baru();hapus();
weight();
Penjelasan Code Program:
6. menambahkan data baru terdapat pada function lima_Data_Baru()
7. menghapus data tertentu terdapat pada function hapus()
8. data baru terdapat pada function weight()
function weight_baru() {
$weight["Adi"] = "70";
$weight["Ridwan"] = "65";
$weight["Zainal"] = "90";
$newData = array(
array("David", "220404", "0812345601"),
array("Ella", "220405", "0812345602"),
array("Frank", "220406", "0812345603"),
array("Grace", "220407", "0812345604"),
array("Hannah", "220408", "0812345605"),
);
<table border="1">
<thead>
<tr>
<th>Nama</th>
<th>NIM</th>
<th>Nomor Telepon</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $student) : ?>
<tr>
<?php foreach ($student as $data) : ?>
<td><?= $data ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Penjelasan Code Program: