The in_array function is very slow for large arrays due to doing a linear search.
A faster alternative is to search the key of the array.
Thus
if (isset($array[$val]))
is much faster than
if (in_array($val,$array))
for large arrays. However using unicode as array keys will not work.
Is there an alternative way to do this for unicode without resorting to linear searches such as in_array or array_search or generating hashes like md5?