Re: How to check if $string contains Hebrew characters?

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

 



or do the same but with strtr()

Will Fitch wrote:
If your goal is to eventually convert Hebrew chars to something else, you could just use str_replace or stri_replace and have each Hebrew char as an array element, replaced by another array element as a match.

Example in English:

str_replace(array('a','b','c'),array('t','u','v'),$string);

This will replace all instances of a,b and c with t, u, and v respectively. This removes the regex resource.


-----Original Message-----
From: Nitsan Bin-Nun [mailto:nitsanbn@xxxxxxxxx] Sent: Wednesday, June 25, 2008 10:33 AM
To: php php
Subject:  How to check if $string contains Hebrew characters?

Hi,
I have a $string and i want to know if it contains Hebrew characters in it,
I wrote the following:


function containHebrewChars ($string)
{
$chars = "אבגדהוזחטיכלמנסעפצקרשת"; // ABC of hebrew chars (AlefBet)
$chars =
preg_replace("/([\xE0-\xFA])/e","chr(215).chr(ord(\${1})-80)",$chars); //
convert it to UTF8
if (preg_match("/[".$chars."]/", $string)) return true;
return false;
}


I'm pretty sure there is a better way to do this (regex is overkill), any
ideas?

Regards,
Nitsan



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