Skip to content

Instantly share code, notes, and snippets.

@mazhar266
Created February 18, 2012 09:55
Show Gist options
  • Save mazhar266/bd21f7b29730aeff86d1 to your computer and use it in GitHub Desktop.
Save mazhar266/bd21f7b29730aeff86d1 to your computer and use it in GitHub Desktop.
strlen of utf8 unicode characters
<?php
function utf8_strlen ($s)
{
$c = strlen($s); $l = 0;
for ($i = 0; $i < $c; ++$i)
if ((ord($s[$i]) & 0xC0) != 0x80)
++$l;
return $l;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment