“Hapus Nilai Array PHP” Kode Jawaban

PHP menghapus item array berdasarkan nilai

$colors = array("blue","green","red");

//delete element in array by value "green"
if (($key = array_search("green", $colors)) !== false) {
    unset($colors[$key]);
}
Grepper

Menghapus elemen dari array dalam php

$array = [0 => "a", 1 => "b", 2 => "c"];
unset($array[1]); //Key which you want to delete
/*
$array:
[
    [0] => a
    [2] => c
]
*/
//OR
$array = [0 => "a", 1 => "b", 2 => "c"];
array_splice($array, 1, 1);//Offset which you want to delet
/*
$array:
[
    [0] => a
    [1] => c
]
*/
Matteoweb

Hapus Nilai Array PHP

array_splice(array, start, length, array)
Smiling Shark

Jawaban yang mirip dengan “Hapus Nilai Array PHP”

Pertanyaan yang mirip dengan “Hapus Nilai Array PHP”

Lebih banyak jawaban terkait untuk “Hapus Nilai Array PHP” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya