protected static function _strlen($text, array $options)
    {
        if (empty($options['trimWidth'])) {
            $strlen = 'mb_strlen';
        } else {
            $strlen = 'mb_strwidth';
        }

        if (empty($options['html'])) {
            return $strlen($text);
        }

        $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
        $replace = preg_replace_callback(
            $pattern,
            function ($match) use ($strlen) {
                $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');

                return str_repeat(' ', $strlen($utf8, 'UTF-8'));
            },
            $text
        );

        return $strlen($replace);
    }
protected static function _strlen($text, array $options)
    {
        if (empty($options['trimWidth'])) {
            $strlen = 'mb_strlen';
        } else {
            $strlen = 'mb_strwidth';
        }

        if (empty($options['html'])) {
            return $strlen($text);
        }

        $pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i';
        $replace = preg_replace_callback(
            $pattern,
            function ($match) use ($strlen) {
                $utf8 = html_entity_decode($match[0], ENT_HTML5 | ENT_QUOTES, 'UTF-8');

                return str_repeat(' ', $strlen($utf8, 'UTF-8'));
            },
            $text
        );

        return $strlen($replace);
    }
protected static function _strlen ( $ text , array $ options ) { if ( empty ( $ options [ 'trimWidth' ] ) ) { $ strlen = 'mb_strlen' ; } else { $ strlen = 'mb_strwidth' ; } if ( empty ( $ options [ 'html' ] ) ) { return $ strlen ( $ text ) ; } $ pattern = '/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i' ; $ replace = preg_replace_callback ( $ pattern , function ( $ match ) use ( $ strlen ) { $ utf8 = html_entity_decode ( $ match [ 0 ] , ENT_HTML5 | ENT_QUOTES , 'UTF-8' ) ; return str_repeat ( ' ' , $ strlen ( $ utf8 , 'UTF-8' ) ) ; } , $ text ) ; return $ strlen ( $ replace ) ; }
Get string length.

### Options:

- `html` If true, HTML entities will be handled as decoded characters.
- `trimWidth` If true, the width will return.

@param string $text The string being checked for length
@param array $options An array of options.
@return int
Get string length .