note 110337 deleted from function.strlen by googleguy

From: Date: Fri, 12 Oct 2012 10:59:04 +0000
Subject: note 110337 deleted from function.strlen by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191270@lists.php.net to get a copy of this message
Note Submitter: qeremy [atta] gmail [dotta] com ---- A dirty (proper) way to get the real length of charters (not byte length). <?php function strlen_unicode($str) { return count(preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY)); } $s = "Büyük"; echo strlen_unicode($s); // 5 echo mb_strlen($s); // 7 echo strlen($s); // 7 ?>

« previous php.notes (#191270) next »