Contents

BBCodeLexer::GuessTextLength()

Description

Source

File: bp-forums/admin/parser.php

function GuessTextLength() {
$length = 0;
$ptr = 0;
$state = BBCODE_LEXSTATE_TEXT;
while ($ptr < count($this->input)) {
$text = $this->input[$ptr++];
if ($state == BBCODE_LEXSTATE_TEXT) {
$state = BBCODE_LEXSTATE_TAG;
$length += strlen($text);
}
else {
switch (ord(substr($this->text, 0, 1))) {
case 10:
case 13:
$state = BBCODE_LEXSTATE_TEXT;
$length++;
break;
default:
$state = BBCODE_LEXSTATE_TEXT;
$length += strlen($text);
break;
case 40:
case 60:
case 91:
case 123:
$state = BBCODE_LEXSTATE_TEXT;
break;
}
}
}
return $length;
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.