src/Utility/Hash.php
public static function remove(array $data, $path)
    {
        $noTokens = strpos($path, '[') === false;
        $noExpansion = strpos($path, '{') === false;

        if ($noExpansion && $noTokens && strpos($path, '.') === false) {
            unset($data[$path]);

            return $data;
        }

        $tokens = $noTokens ? explode('.', $path) : Text::tokenize($path, '.', '[', ']');

        if ($noExpansion && $noTokens) {
            return static::simpleOp('remove', $data, $tokens);
        }

        $token = array_shift($tokens);
        $nextPath = implode('.', $tokens);

        list($token, $conditions) = self::splitConditions($token);

        foreach ($data as $k => $v) {
            $match = static::matchToken($k, $token);
            if ($match && is_array($v)) {
                if ($conditions) {
                    if (static::matches($v, $conditions)) {
                        if ($nextPath) {
                            $data[$k] = static::remove($v, $nextPath);
                        } else {
                            unset($data[$k]);
                        }
                    }
                } else {
                    $data[$k] = static::remove($v, $nextPath);
                }
                if (empty($data[$k])) {
                    unset($data[$k]);
                }
            } elseif ($match && empty($nextPath)) {
                unset($data[$k]);
            }
        }

        return $data;
    }
public static function remove(array $data, $path)
    {
        $noTokens = strpos($path, '[') === false;
        $noExpansion = strpos($path, '{') === false;

        if ($noExpansion && $noTokens && strpos($path, '.') === false) {
            unset($data[$path]);

            return $data;
        }

        $tokens = $noTokens ? explode('.', $path) : Text::tokenize($path, '.', '[', ']');

        if ($noExpansion && $noTokens) {
            return static::simpleOp('remove', $data, $tokens);
        }

        $token = array_shift($tokens);
        $nextPath = implode('.', $tokens);

        list($token, $conditions) = self::splitConditions($token);

        foreach ($data as $k => $v) {
            $match = static::matchToken($k, $token);
            if ($match && is_array($v)) {
                if ($conditions) {
                    if (static::matches($v, $conditions)) {
                        if ($nextPath) {
                            $data[$k] = static::remove($v, $nextPath);
                        } else {
                            unset($data[$k]);
                        }
                    }
                } else {
                    $data[$k] = static::remove($v, $nextPath);
                }
                if (empty($data[$k])) {
                    unset($data[$k]);
                }
            } elseif ($match && empty($nextPath)) {
                unset($data[$k]);
            }
        }

        return $data;
    }
Remove data matching $path from the $data array.
You can use `{n}` and `{s}` to remove multiple elements
from $data.

@param array $data The data to operate on
@param string $path A path expression to use to remove.

@return array The modified array.