php unset array key
unset($dataArray['key']);
php delete element from array
//Delete array items with unset(no re-index) or array_splice(re-index)
$colors = array("red","blue","green");
unset($colors[1]);//remove second element, do not re-index array
$colors = array("red","blue","green");
array_splice($colors, 1, 1); //remove second element, re-index array
php erase element from array
foreach ($items as $key =>$item){
if(condition){
unset($item[$key]);
}
}
php array remove keys keep values
<?php
$array = array("size" => "XL", "color" => "gold");
print_r(array_values($array));
?>
Array
(
[0] => XL
[1] => gold
)
remove key of an array php
$result_Member = $this->Member->get_list_member_belong_to_company($id);
/*
$result_Member = array(
[10] => 10,
[20] => 11,
[30] => 12,
)
*/
// remove key, get values only
$member_ids = array_values($result_Member);
/*
$result_Member = array(
[0] => 10,
[1] => 11,
[2] => 12,
)
*/
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us