src/PHPHtmlParser/Content.php
public function copyUntilUnless(string $string, string $unless)
    {
        $lastPos = $this->pos;
        $this->fastForward(1);
        $foundString = $this->copyUntil($string, true, true);

        $position = strcspn($foundString, $unless);
        if ($position == strlen($foundString)) {
            return $string.$foundString;
        }
        // rewind changes and return nothing
        $this->pos = $lastPos;

        return '';
    }
public function copyUntilUnless(string $string, string $unless)
    {
        $lastPos = $this->pos;
        $this->fastForward(1);
        $foundString = $this->copyUntil($string, true, true);

        $position = strcspn($foundString, $unless);
        if ($position == strlen($foundString)) {
            return $string.$foundString;
        }
        // rewind changes and return nothing
        $this->pos = $lastPos;

        return '';
    }
public function copyUntilUnless ( string $ string , string $ unless ) { $ lastPos = $ this -> pos ; $ this -> fastForward ( 1 ) ; $ foundString = $ this -> copyUntil ( $ string , true , true ) ; $ position = strcspn ( $ foundString , $ unless ) ; if ( $ position == strlen ( $ foundString ) ) { return $ string . $ foundString ; } // rewind changes and return nothing $ this -> pos = $ lastPos ; return '' ; }
Copies the content until the string is found and return it
unless the 'unless' is found in the substring.

@param string $string
@param string $unless
@return string
Copies the content until the string is found and return it unless the unless is found in the substring .