php delete element by value
$colors = array("blue","green","red");
//delete element in array by value "green"
if (($key = array_search("green", $colors)) !== false) {
unset($colors[$key]);
}
php delete element by value
$colors = array("blue","green","red");
//delete element in array by value "green"
if (($key = array_search("green", $colors)) !== false) {
unset($colors[$key]);
}
how to remove keys in subarray php
print_r(deep_delete_keys($arr,'country'));
function deep_delete_keys($arr, $keys) {
if (!is_array($keys)) $keys = array($keys);
$filteredArr = array_diff_key( $arr, array_flip( $keys ) );
foreach ($filteredArr as &$val) {
if (is_array($val)) {
$val = deep_delete_keys($val, $keys);
}
}
return $filteredArr;
}
php array remove key value pair
unset($array['key-here']);
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