Advertisement
aldinokemal

Array Manipulation - Remove data

Sep 25th, 2022
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $dataHari = ['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu'];
  3.  
  4. # Menghapus data (diakhir)
  5. array_pop($dataHari); // menghapus hari sabtu
  6.  
  7. # Menghapus data (ditengah by indeks)
  8. array_splice($dataHari, 2, 1); // menghapus hari selasa
  9.  
  10. # Menghapus data (diawal)
  11. array_shift($dataHari); // menghapus hari minggu
  12.  
  13. print_r($dataHari);
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement