Logo

Programming-Idioms

History of Idiom 169 > diff from v99 to v100

Edit summary for version 100 by programming-idioms.org:
[PHP] Emphasize in comments

Version 99

2022-02-01, 22:56:31

Version 100

2022-02-06, 16:44:33

Idiom #169 String length

Assign to integer n the number of characters of string s.
Make sure that multibyte characters are properly handled.
n can be different from the number of bytes of s.

Idiom #169 String length

Assign to integer n the number of characters of string s.
Make sure that multibyte characters are properly handled.
n can be different from the number of bytes of s.

Variables
n,s
Variables
n,s
Extra Keywords
size characters chars number runes
Extra Keywords
size characters chars number runes
Code
$n = mb_strlen($s, 'UTF-8');
Code
$n = mb_strlen($s, 'UTF-8');
Comments bubble
returns the number of characters in the UTF-8 string s
Comments bubble
Returns the number of characters in the UTF-8 string s
Doc URL
https://secure.php.net/manual/en/function.mb-strlen.php
Doc URL
https://secure.php.net/manual/en/function.mb-strlen.php
Demo URL
https://3v4l.org/LGHWj
Demo URL
https://3v4l.org/LGHWj