public static function remove(array &$array, $keyPath)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $result = $array;
        $keys = self::explodeKeys(strval($keyPath));
        $ptr = &$result;

        while ($keys !== array()) {
            $key = array_shift($keys);

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = array();
                $ptr = &$ptr[$key];
                continue;
            }
            $prevPtr = &$ptr;
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                unset($prevPtr[$key]);
                $array = $result;
                return;
            }
            elseif (!is_array($ptr)) {
                throw new KeyNotFound($keyPath);
            }
        }

        throw new KeyNotFound($keyPath);
    }
public static function remove(array &$array, $keyPath)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $result = $array;
        $keys = self::explodeKeys(strval($keyPath));
        $ptr = &$result;

        while ($keys !== array()) {
            $key = array_shift($keys);

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = array();
                $ptr = &$ptr[$key];
                continue;
            }
            $prevPtr = &$ptr;
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                unset($prevPtr[$key]);
                $array = $result;
                return;
            }
            elseif (!is_array($ptr)) {
                throw new KeyNotFound($keyPath);
            }
        }

        throw new KeyNotFound($keyPath);
    }
public static function remove ( array & $ array , $ keyPath ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ result = $ array ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ ptr = & $ result ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; if ( ! array_key_exists ( $ key , $ ptr ) ) { $ ptr [ $ key ] = array ( ) ; $ ptr = & $ ptr [ $ key ] ; continue ; } $ prevPtr = & $ ptr ; $ ptr = & $ ptr [ $ key ] ; if ( $ keys === array ( ) ) { unset ( $ prevPtr [ $ key ] ) ; $ array = $ result ; return ; } elseif ( ! is_array ( $ ptr ) ) { throw new KeyNotFound ( $ keyPath ) ; } } throw new KeyNotFound ( $ keyPath ) ; }
Remove a value from a key path in an array and return the array.

@param array $array
@param string $keyPath
@return void

@throws KeyNotFound
@throws BadKeyPath
Remove a value from a key path in an array and return the array .