Re: Checking how many letters are in a string.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is the question:

"How do I tell how many characters are in a string that may contain Hebrew characters?"

or is the question...

"How do I tell how many Hebrew characters are in a string that may contain Hebrew and non-Hebrew characters.. but I only want a count of the Hebrew characters?"

or maybe even...

"How do I tell if there are Hebrew characters in a string?   Regardless of actual count?"


The mb_strlen() sounds like it would work for the first question, but that's not exactly what you asked.  What you asked was closer to the second question, which wouldn't be solved by using mb_strlen() I believe.   In the second two cases, you might be able to use a preg_match type search.

If no other functions work, you could parse the string into an array and compare against an array containing hebrew characters.

-TG

----- Original Message -----
From: "Dotan Cohen" <dotancohen@xxxxxxxxx>
To: php <php-general@xxxxxxxxxxxxx>
Date: Wed, 19 Mar 2008 18:39:19 +0200
Subject:  Checking how many letters are in a string.

> 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 Cohen

http://what-is-what.com
http://gibberish.co.il
×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-×?-× -ס-×¢-×£-פ-×¥-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux