Advertisement
aldinokemal

Array Manipulation - Add data

Sep 25th, 2022
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $dataHari = ['Senin','Selasa','Kamis','Jumat'];
  3.  
  4. # Menambah data di akhir
  5. array_push($dataHari, "Sabtu");
  6.  
  7. # Menambah data (ditengah by indeks)
  8. array_splice($dataHari, 2, 0, "Rabu");
  9.  
  10. # Menambah data (diawal)
  11. array_unshift($dataHari, "Minggu");
  12.  
  13. print_r($dataHari);
  14.  
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement