Removes an element from the array.

@see http://stackoverflow.com/a/16698855/1399706

@param array  $array
@param string $path
516029
public function rm(array &$array, string $path): void
    {
        // This way it will trigger an error if the calculated value is not correct
        $node = null;
        $path = new PropertyPathBuilder($path);

        $nodes        = $path->getPropertyPath()->getElements();
        $parentLevel  = null;
        $currentLevel = &$array;
        foreach ($nodes as &$node) {
            $parentLevel  = &$currentLevel;
            $currentLevel = &$currentLevel[$node];
        }

        if (null !== $parentLevel) {
            unset($parentLevel[$node]);
        }
    }
809395
public function remove_path($path)
	{
		foreach ($this->paths as $i => $p)
		{
			if ($p === $path)
			{
				unset($this->paths[$i]);
				break;
			}
		}

		return $this;
	}
169881
public function remove(array $path)
    {
        $current    = &$this->hierarchy;
        $pathLength = count($path);
        for ($i = 0; $i < $pathLength; $i++) {
            if (!isset($current[$path[$i]])) {
                break;
            }
            if ($i === $pathLength - 1) {
                unset($current[$path[$i]]);
                break;
            }
            $current = &$current[$path[$i]];
        }
    }
1160090
public static function delete(array $array, string ...$paths): array
    {
        if (empty($paths)) {
            throw new \ArgumentCountError('Too few arguments to function xobotyi\A::delete(), 1 passed, at least 2 expected');
        }

        foreach ($paths as &$path) {
            if ($path === '') {
                continue;
            }


            $path = self::splitPath($path);

            if (empty($path)) {
                continue;
            }

            $scope = &$array;

            for ($i = 0; $i < count($path) - 1; $i++) {
                if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) {
                    continue 2;
                }

                $scope = &$scope[$path[$i]];
            }

            unset($scope[$path[$i]]);
        }

        return $array;
    }
494500
public static function has(array $array, string $path): bool
	{
		$segments = explode('.', $path);

		foreach($segments as $segment)
		{
			if(!is_array($array) || !array_key_exists($segment, $array))
			{
				return false;
			}

			$array = $array[$segment];
		}

		return true;
	}
306484
public function removeIgnoredPath($path)
    {
        array_remove_value($this->ignoredPaths, $path);
        $this->ignoredPaths = array_values($this->ignoredPaths);
    }
115178
public static function has(array $array, string $path): bool
    {
        $paths = explode('.', $path);
        $temp = $array;
        while ($key = array_shift($paths)) {
            if (isset($temp[$key])) {
                $temp = $temp[$key];
            } else {
                return false;
            }
        }
        return true;
    }
49202
private function delete(array &$array, $key)
    {
        $key = trim($key, '.');
        if (strpos($key, '.') !== false) {
            $explode = explode('.', $key);
            $this->delete($array[$explode[0]], $explode[1]);
        } else {
            unset($array[$key]);
        }
    }
1051906
public static function delete(&$array, $key)
	{
		if (is_null($key))
		{
			return false;
		}

		if (is_array($key))
		{
			$return = array();
			foreach ($key as $k)
			{
				$return[$k] = static::delete($array, $k);
			}
			return $return;
		}

		$key_parts = explode('.', $key);

		if (! is_array($array) or ! array_key_exists($key_parts[0], $array))
		{
			return false;
		}

		$this_key = array_shift($key_parts);

		if (! empty($key_parts))
		{
			$key = implode('.', $key_parts);
			return static::delete($array[$this_key], $key);
		}
		else
		{
			unset($array[$this_key]);
		}

		return true;
	}
711059
public function deleteRecursive($path)
	{
		if (!$this->tryDelete($path)) {
			foreach ((array) $this->nlist($path) as $file) {
				if ($file !== '.' && $file !== '..') {
					$this->deleteRecursive(strpos($file, '/') === FALSE ? "$path/$file" : $file);
				}
			}
			$this->rmdir($path);
		}
	}
755254
public function isWritable(array $array, string $path): bool
    {
        if ($this->isRoot($path)) {
            return false;
        }

        try {
            $this->pa->getValue($array, $path);
        } catch (NoSuchIndexException $e) {
            // If the exception is thrown, the value can be written at given $path as it hasn't already a value
            return true;
        }

        return false;
    }
1240219
public static function delete(array &$values, $path)
    {
        /** @noinspection ReferenceMismatchInspection */
        if (!static::isArray($values)) {
            // This is not an array!
            return false;
        }

        if (is_array($path)) {
            // The path has already been separated into segments
            $segments = $path;
        } else {
            $path = (string) $path;

            // Remove starting delimiters and spaces
            $path = ltrim($path, sprintf('%s ', static::PATH_DELIMITER));
            // Remove ending delimiters, spaces, and wildcards
            $path = rtrim($path, sprintf('%s %s', static::PATH_DELIMITER, static::PATH_WILDCARD));
            // Split the segments by delimiter
            $segments = explode(static::PATH_DELIMITER, $path);
        }

        while (count($segments) > 1) {
            $key = array_shift($segments);

            /** @noinspection ReferenceMismatchInspection */
            if (!array_key_exists($key, $values) || !is_array($values[$key])) {
                return false;
            }

            $values =& $values[$key];
        }

        unset($values[array_shift($segments)]);

        return true;
    }
911338
protected function removeDirectory($path)
    {
        if (!is_dir($path)) {
            return;
        }

        foreach (scandir($path) as $entry) {
            if ($entry === '.' || $entry === '..') {
                continue;
            }

            $entryPath = $path . '/' . $entry;

            if (is_dir($entryPath)) {
                $this->removeDirectory($entryPath);
            } else {
                unlink($entryPath);
            }
        }

        rmdir($path);
    }
416584
public static function remove($path)
    {
        if (is_dir($path)) {
            if (false === ($dir = opendir($path))) {
                throw FileException::removeFailed($path);
            }

            while (false !== ($item = readdir($dir))) {
                if (('.' === $item) || ('..' === $item)) {
                    continue;
                }

                self::remove($path . DIRECTORY_SEPARATOR . $item);
            }

            closedir($dir);

            if (!rmdir($path)) {
                throw FileException::removeFailed($path);
            }
        } elseif (!unlink($path)) {
            throw FileException::removeFailed($path);
        }
    }
72622
public function disallowDirectory($path)
	{
		if (is_array($path))
			foreach ($path as $dir)
				unset($this->allowedDirectories[realpath($dir)]);
		else
			unset($this->allowedDirectories[realpath($path)]);
	}
783024
protected function clearDirectory($path)
    {
        $iterator = new \DirectoryIterator($path);

        /** @var \DirectoryIterator $fileinfo */
        foreach ($iterator as $fileinfo) {
            if ($fileinfo->isDot()) {
                continue;
            }

            if ($fileinfo->isFile() || $fileinfo->isLink()) {
                @unlink($fileinfo->getPathname());
            } elseif ($fileinfo->isDir()) {
                $this->clearDirectory($fileinfo->getPathname());
            }
        }
    }
724438
public function delete($paths) {
		$paths = is_array($paths) ? $paths : func_get_args();
		$success = true;

		foreach ($paths as $path) {
			try {
				if (! @unlink($path)) {
					$success = false;
				}
			} catch (Exception $e) {
				$success = false;
			}
		}
		return $success;
	}