src/ArkHelper.php
public static function removeFromArray(&$array, $keychain)
    {
        if (!is_array($array)) {
            $array = [];
        }
        if (!is_array($keychain)) {
            $keychain = [$keychain];
        }

        $headKey = array_shift($keychain);
        if (empty($keychain)) {
            //last
            unset($array[$headKey]);
        } else {
            //not last
            if (isset($array[$headKey])) {
                self::removeFromArray($array[$headKey], $keychain);
            }
        }
    }
public static function removeFromArray(&$array, $keychain)
    {
        if (!is_array($array)) {
            $array = [];
        }
        if (!is_array($keychain)) {
            $keychain = [$keychain];
        }

        $headKey = array_shift($keychain);
        if (empty($keychain)) {
            //last
            unset($array[$headKey]);
        } else {
            //not last
            if (isset($array[$headKey])) {
                self::removeFromArray($array[$headKey], $keychain);
            }
        }
    }
public static function removeFromArray ( & $ array , $ keychain ) { if ( ! is_array ( $ array ) ) { $ array = [ ] ; } if ( ! is_array ( $ keychain ) ) { $ keychain = [ $ keychain ] ; } $ headKey = array_shift ( $ keychain ) ; if ( empty ( $ keychain ) ) { //last unset ( $ array [ $ headKey ] ) ; } else { //not last if ( isset ( $ array [ $ headKey ] ) ) { self :: removeFromArray ( $ array [ $ headKey ] , $ keychain ) ; } } }
Unset item and nested item in array
@since 1.2
@param array $array
@param array|string|int $keychain
Unset item and nested item in array