Update base.php

This commit is contained in:
Namhyeon Go 2020-02-26 16:12:10 +09:00 committed by GitHub
parent a920baaa83
commit cd3a446a54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -258,18 +258,12 @@ if(!is_fn("array_key_is_array")) {
}
}
if(!is_fn("array_key_unset")) {
function array_key_unset($key, $array) {
$_array = array();
// alternative to `unset($array[$key])`
foreach($array as $k=>$v) {
if($k != $key) {
$_array[$k] = $v;
}
// example: array_key_unset(array_search("apple", $fruits), $fruits);
if(!check_function_exists("array_key_unset")) {
function array_key_unset($key, &$array) {
if(array_key_exists($key, $array)) {
unset($array[$key]);
}
return $_array;
}
}