Re: Checking how many letters are in a string.
| From: | tedd | Date: | Wed, 19 Mar 2008 16:57:13 +0000 |
| Subject: | Re: Checking how many letters are in a string. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271829@lists.php.net to get a copy of this message | ||
At 6:39 PM +0200 3/19/08, Dotan Cohen wrote:
I need to count how many Hebrew characters a given string has. I have been checking, character by character, if the given character is a [ý] and if so I simply ++ the counting variable. It turns out that this is rather resouce intensive, and I may need a better way of doing this. I have looked at count_chars and considered writing a wrapper function for each of the 27 letters of the Hebrew alphabet, but I am quite sure that there is a cleverer method. Any ideas? Dotan CohenDotan: Are you using mb_<whatever> functions? Hebrew characters are not ASCII and as such may contain graphemes and ligatures. You need to use Unicode safe routines (i.e., mb_strlen() etc. ) for string manipulations. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com