public static remove ( array &$array, string $key, mixed $default = null ) : mixed | null | ||
$array | array | the array to extract value from |
$key | string | key name of the array element |
$default | mixed | the default value to be returned if the specified key does not exist |
return | mixed | null | the value of the element if found, default value otherwise |
public static function remove(&$array, $key, $default = null)
{
if (is_array($array) && (isset($array[$key]) || array_key_exists($key, $array))) {
$value = $array[$key];
unset($array[$key]);
return $value;
}
return $default;
}