You are here

public function StringInputStream::charsWhile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php \Masterminds\HTML5\Parser\StringInputStream::charsWhile()

Returns the string so long as $bytes matches.

Matches as far as possible with a certain set of bytes and returns the matched substring.

Parameters

string $bytes: A mask of bytes to match. If ANY byte in this mask matches the current char, the pointer advances and the char is part of the substring.

int $max: The max number of chars to read.

Overrides InputStream::charsWhile

File

vendor/masterminds/html5/src/HTML5/Parser/StringInputStream.php, line 285

Class

StringInputStream

Namespace

Masterminds\HTML5\Parser

Code

public function charsWhile($bytes, $max = null) {
  if ($this->char >= $this->EOF) {
    return false;
  }
  if ($max === 0 || $max) {
    $len = strspn($this->data, $bytes, $this->char, $max);
  }
  else {
    $len = strspn($this->data, $bytes, $this->char);
  }
  $string = (string) substr($this->data, $this->char, $len);
  $this->char += $len;
  return $string;
}