yii\helpers\BaseArrayHelper::remove PHP Method

remove() public static method

Usage examples, php $array = ['type' => 'A', 'options' => [1, 2]]; working with array $type = \yii\helpers\ArrayHelper::remove($array, 'type'); $array content $array = ['options' => [1, 2]];
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;
    }