“PHP Unset Array Key” 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

PHP Unset Array Key

unset($dataArray['key']);
Xanthous Xenomorph

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

tidak terikat dengan nama kunci php

unset($array['key-here']);
Thankful Toucan

Jawaban yang mirip dengan “PHP Unset Array Key”

Pertanyaan yang mirip dengan “PHP Unset Array Key”

Lebih banyak jawaban terkait untuk “PHP Unset Array Key” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya