protected function shave()
    {
        preg_match("/<[^>]+>/", $this->chunk, $matches, PREG_OFFSET_CAPTURE);

        if (isset($matches[0], $matches[0][0], $matches[0][1])) {
            list($captured, $offset) = $matches[0];

            if ($this->options["expectGT"]) {
                // Some elements support > inside
                foreach ($this->options["tagsWithAllowedGT"] as $tag) {
                    list($opening, $closing) = $tag;

                    if (substr($captured, 0, strlen($opening)) === $opening) {
                        // We have a match, our preg_match may have ended too early
                        // Most often, this isn't the case
                        if (substr($captured, -1 * strlen($closing)) !== $closing) {
                            // In this case, the preg_match ended too early, let's find the real end
                            $position = strpos($this->chunk, $closing);
                            if ($position === false) {
                                // We need more XML!

                                return false;
                            }

                            // We found the end, modify $captured
                            $captured = substr($this->chunk, $offset, $position + strlen($closing) - $offset);
                        }
                    }
                }
            }

            // Data in between
            $data = substr($this->chunk, 0, $offset);

            // Shave from chunk
            $this->chunk = substr($this->chunk, $offset + strlen($captured));

            return array($captured, $data . $captured);
        }

        return false;
    }
protected function shave()
    {
        preg_match("/<[^>]+>/", $this->chunk, $matches, PREG_OFFSET_CAPTURE);

        if (isset($matches[0], $matches[0][0], $matches[0][1])) {
            list($captured, $offset) = $matches[0];

            if ($this->options["expectGT"]) {
                // Some elements support > inside
                foreach ($this->options["tagsWithAllowedGT"] as $tag) {
                    list($opening, $closing) = $tag;

                    if (substr($captured, 0, strlen($opening)) === $opening) {
                        // We have a match, our preg_match may have ended too early
                        // Most often, this isn't the case
                        if (substr($captured, -1 * strlen($closing)) !== $closing) {
                            // In this case, the preg_match ended too early, let's find the real end
                            $position = strpos($this->chunk, $closing);
                            if ($position === false) {
                                // We need more XML!

                                return false;
                            }

                            // We found the end, modify $captured
                            $captured = substr($this->chunk, $offset, $position + strlen($closing) - $offset);
                        }
                    }
                }
            }

            // Data in between
            $data = substr($this->chunk, 0, $offset);

            // Shave from chunk
            $this->chunk = substr($this->chunk, $offset + strlen($captured));

            return array($captured, $data . $captured);
        }

        return false;
    }
protected function shave ( ) { preg_match ( "/<[^>]+>/" , $ this -> chunk , $ matches , PREG_OFFSET_CAPTURE ) ; if ( isset ( $ matches [ 0 ] , $ matches [ 0 ] [ 0 ] , $ matches [ 0 ] [ 1 ] ) ) { list ( $ captured , $ offset ) = $ matches [ 0 ] ; if ( $ this -> options [ "expectGT" ] ) { // Some elements support > inside foreach ( $ this -> options [ "tagsWithAllowedGT" ] as $ tag ) { list ( $ opening , $ closing ) = $ tag ; if ( substr ( $ captured , 0 , strlen ( $ opening ) ) === $ opening ) { // We have a match, our preg_match may have ended too early // Most often, this isn't the case if ( substr ( $ captured , - 1 * strlen ( $ closing ) ) !== $ closing ) { // In this case, the preg_match ended too early, let's find the real end $ position = strpos ( $ this -> chunk , $ closing ) ; if ( $ position === false ) { // We need more XML! return false ; } // We found the end, modify $captured $ captured = substr ( $ this -> chunk , $ offset , $ position + strlen ( $ closing ) - $ offset ) ; } } } } // Data in between $ data = substr ( $ this -> chunk , 0 , $ offset ) ; // Shave from chunk $ this -> chunk = substr ( $ this -> chunk , $ offset + strlen ( $ captured ) ) ; return array ( $ captured , $ data . $ captured ) ; } return false ; }
Shaves off the next element from the chunk
@return string[]|bool Either a shaved off element array(0 => Captured element, 1 => Data from last shaving point up to and including captured element) or false if one could not be obtained
Shaves off the next element from the chunk