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" <[EMAIL PROTECTED]>
To: php <php-general@lists.php.net>
Date: Wed, 19 Mar 2008 18:39:19 +0200
Subject: [PHP] 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

Reply via email to