note 126670 added to function.grapheme-strlen
| From: | jonhoggg at gmail dot com | Date: | Thu, 09 Dec 2021 04:08:16 +0000 |
| Subject: | note 126670 added to function.grapheme-strlen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217341@lists.php.net to get a copy of this message | ||
You can use grapheme_strlen() to count emojis as a single character:
<?php
echo strlen('ð´ó §ó ¢ó ¥ó ®ó §ó ¿'); //28 - oh no
echo mb_strlen('ð´ó §ó ¢ó ¥ó ®ó §ó ¿'); // -
closer, but no
echo grapheme_strlen('ð´ó §ó ¢ó ¥ó ®ó §ó ¿'); //1
- Bingo
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 84.65.173.21)
----
Manual Page -- https://php.net/manual/en/function.grapheme-strlen.php
Edit -- https://main.php.net/note/edit/126670
Del: integrated -- https://main.php.net/note/delete/126670/integrated
Del: useless -- https://main.php.net/note/delete/126670/useless
Del: bad code -- https://main.php.net/note/delete/126670/bad+code
Del: spam -- https://main.php.net/note/delete/126670/spam
Del: non-english -- https://main.php.net/note/delete/126670/non-english
Del: in docs -- https://main.php.net/note/delete/126670/in+docs
Del: other reasons-- https://main.php.net/note/delete/126670
Reject -- https://main.php.net/note/reject/126670
Search -- https://main.php.net/manage/user-notes.php