Function Reference: geodir_strlen
Summary
Get string length.
Description
### Options:
– `html` If true, HTML entities will be handled as decoded characters.
– `trimWidth` If true, the width will return.
Package
GeoDirectory
Parameters
- $text
- (string) (required) The string being checked for length.
- Default: None
- $options
- (array) (required) {
An array of options. @type bool $html If true, HTML entities will be handled as decoded characters. @type bool $trimWidth If true, the width will return. }.- Default: None
Return Values
- (int)
Change Log
Since: 1.6.16
Source File
geodir_strlen() is located in geodirectory-functions/helper_functions.php [Line: 836]
Source Code
function geodir_strlen($text, array $options) { if (empty($options['trimWidth'])) { $strlen = 'geodir_utf8_strlen'; } else { $strlen = 'geodir_utf8_strwidth'; } if (empty($options['html'])) { return $strlen($text); } $pattern = '/&[0-9a-z]{2,8};|[0-9]{1,7};|[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); }