HTMLPurifier_Lexer_DirectLex::substrCount PHP Method

substrCount() protected method

PHP 5.0.x compatible substr_count that implements offset and length
protected substrCount ( string $haystack, string $needle, integer $offset, integer $length ) : integer
$haystack string
$needle string
$offset integer
$length integer
return integer
    protected function substrCount($haystack, $needle, $offset, $length)
    {
        static $oldVersion;
        if ($oldVersion === null) {
            $oldVersion = version_compare(PHP_VERSION, '5.1', '<');
        }
        if ($oldVersion) {
            $haystack = substr($haystack, $offset, $length);
            return substr_count($haystack, $needle);
        } else {
            return substr_count($haystack, $needle, $offset, $length);
        }
    }