search engine (regexp?)

From: Date: Mon, 03 May 2004 11:12:21 +0000
Subject: search engine (regexp?)
Groups: php.general 
Request: Send a blank email to php-general+get-185181@lists.php.net to get a copy of this message
i'm making a searchengine which searches for recipes (the name, the ingredients and/or the method) searching for one word isn't a problem, even searching for multiple words isn't a problem but it is a problem if i search for something like this: "peeled and diced" fresh if i search for 'peeled and diced fresh' (without quotes) it is changed to 'peeled%and%diced%fresh', so mysql searches for all of the words seperately. when i use the " ("), i would like to search for that whole string, so it would search for 'peeled and diced' and for 'fresh' how should i do that? i have this piece of code: $q = htmlspecialchars($_GET["q"]); // where $_GET["q"] = "peeled and diced" fresh if (preg_match("/\\\\"(.+)\\\\"/", $q)) { $q = preg_replace("/\\\\"(.+)\\\\"/", "\\1", $q); } else { $q = str_replace(" ", "%", $q); $q = str_replace("+", "%", $q); } what happens here is that if there are "-s, then the quotes are removed, but $q will be 'peeled and diced fresh' (without quotes). i think/believe it should be: 'peeled and diced%fresh' (without quotes)

« previous php.general (#185181) next »