| 
 Posted by Carl Vondrick on 04/01/06 09:45 
Jesper wrote: 
 
> I'm going to use a lot of searches for occurences of words in a long text: 
>         $string = "a 500 character Text"; 
>         if (eregi("text", $string)) { print "found";} 
>  
> Eregi should be very slow, so I'm looking for alternatives. Any 
> suggestions? I guess I could use something like 
>         $string = strtolower($string); 
>         if ( strpos($string, "text") !== false ) { print "found";} 
>  
> Is that the best solution? 
 
Your best bet is to use stripos().  This is already case-insensitive. 
 
Carl
 
  
Navigation:
[Reply to this message] 
 |