note 85279 added to function.strlen
| From: | jonathan dot protzenko at gmail dot com | Date: | Sat, 23 Aug 2008 14:35:11 +0000 |
| Subject: | note 85279 added to function.strlen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143767@lists.php.net to get a copy of this message | ||
paolo dot mosna at gmail dot com's solution for getting the length of a unicode string
didn't work for me. Instead, I used the following dirty function (which can be surely improved,
but I'm giving the idea) :
<?php
function ustrlen($s) {
$a = preg_split("//u", $s);
$i = -2;
foreach ($a as $b)
$i++;
return $i;
}
?>
This will return the correct length for any unicode string.
----
Server IP: 217.174.223.124
Probable Submitter: 82.234.196.129
----
Manual Page -- http://www.php.net/manual/en/function.strlen.php
Edit -- https://master.php.net/note/edit/85279
Del: integrated -- https://master.php.net/note/delete/85279/integrated
Del: useless -- https://master.php.net/note/delete/85279/useless
Del: bad code -- https://master.php.net/note/delete/85279/bad+code
Del: spam -- https://master.php.net/note/delete/85279/spam
Del: non-english -- https://master.php.net/note/delete/85279/non-english
Del: in docs -- https://master.php.net/note/delete/85279/in+docs
Del: other reasons-- https://master.php.net/note/delete/85279
Reject -- https://master.php.net/note/reject/85279
Search -- https://master.php.net/manage/user-notes.php