Search/Regular Expression problem

From: Date: Thu, 13 Mar 2003 20:48:37 +0000
Subject: Search/Regular Expression problem
Groups: php.general 
Request: Send a blank email to php-general+get-139591@lists.php.net to get a copy of this message
Hi, I am sorry if this problem is too easy but I just can't figure out a way to do this. I am making a search engine and I would have the user to type a sentence to search for. Let's say it is stored in $search. My search enginue will bring up a result IF and only if ALL of the words in $search exist in the result. For example if $search = Vax Useful Commands Then the result is only true if (eregi(".*Vax.*Useful.*Commands.*", 'possible result')) is true Now, I don't know how many words there are in $search initially. How do I do a search like that? I mean if I know $search is 3 words then I can do $words = preg_split("/ /", $search); if (eregi(".*words[0].*words[1].*words[2].*", 'possible result')) { ..... } Even if I know how many words there are, everytime the number of words in $search can be different. Can anybody give me any ideas? Thanks a lot Kelvin

« previous php.general (#139591) next »