note 85279 deleted from function.strlen by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 12:15:33 +0000 |
| Subject: | note 85279 deleted from function.strlen by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189618@lists.php.net to get a copy of this message | ||
Note Submitter: jonathan dot protzenko at gmail dot com
----
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.