public static function remove($data, $key, $delimiter = '.')
    {
        $nodes = static::getPathNodes($key, $delimiter);

        if (!count($nodes)) {
            return $data;
        }

        $node = null;
        $previous = null;
        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (is_object($dataTmp)) {
                if (empty($dataTmp->$node)) {
                    return $data;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp->$node;
            } elseif (is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    return $data;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp[$node];
            } else {
                return $data;
            }
        }

        // Now, path go to the end, means we get latest node, unset value to this node.
        if (is_object($previous)) {
            unset($previous->$node);
        } elseif (is_array($previous)) {
            unset($previous[$node]);
        }

        return $data;
    }
public static function remove($data, $key, $delimiter = '.')
    {
        $nodes = static::getPathNodes($key, $delimiter);

        if (!count($nodes)) {
            return $data;
        }

        $node = null;
        $previous = null;
        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (is_object($dataTmp)) {
                if (empty($dataTmp->$node)) {
                    return $data;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp->$node;
            } elseif (is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    return $data;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp[$node];
            } else {
                return $data;
            }
        }

        // Now, path go to the end, means we get latest node, unset value to this node.
        if (is_object($previous)) {
            unset($previous->$node);
        } elseif (is_array($previous)) {
            unset($previous[$node]);
        }

        return $data;
    }
public static function remove ( $ data , $ key , $ delimiter = '.' ) { $ nodes = static :: getPathNodes ( $ key , $ delimiter ) ; if ( ! count ( $ nodes ) ) { return $ data ; } $ node = null ; $ previous = null ; $ dataTmp = & $ data ; foreach ( $ nodes as $ node ) { if ( is_object ( $ dataTmp ) ) { if ( empty ( $ dataTmp -> $ node ) ) { return $ data ; } $ previous = & $ dataTmp ; $ dataTmp = & $ dataTmp -> $ node ; } elseif ( is_array ( $ dataTmp ) ) { if ( empty ( $ dataTmp [ $ node ] ) ) { return $ data ; } $ previous = & $ dataTmp ; $ dataTmp = & $ dataTmp [ $ node ] ; } else { return $ data ; } } // Now, path go to the end, means we get latest node, unset value to this node. if ( is_object ( $ previous ) ) { unset ( $ previous -> $ node ) ; } elseif ( is_array ( $ previous ) ) { unset ( $ previous [ $ node ] ) ; } return $ data ; }
Remove a value from array or object. The key can be a path separated by dots.

@param array|object $data      Object or array to remove value.
@param string       $key       The key path name.
@param string       $delimiter The separator to split paths.

@return  array|object
Remove a value from array or object . The key can be a path separated by dots .