bcarl314
12-30-2003, 07:38 PM
I've got the following code in my search script...
$query = strtolower($query);
$query = preg_replace("/[^a-zą-’0-9 +!-]/"," ",$query);
$query_arr_dum = preg_split("/\s+/",$query);
$query is the text entered from the user on the search form
$query_arr_dum is an array which is create by seperating each word on the query string (by using a space (\s) as a delimiter. This array is used later on for matching words in the pages in the site.
What I would like to do is, if someone puts a phrase in quotes, that is treated as one work.
right now if you enter
new red house // without quotes
you will get results from pages that contain the word "new" and the word "red" and the work "house" but not necessarily right next to each other.
What I want to do, is have it so if you enter
new "red house"
you will get pages that match the word "new" and the phrase "red house"
How can I make that happen?
$query = strtolower($query);
$query = preg_replace("/[^a-zą-’0-9 +!-]/"," ",$query);
$query_arr_dum = preg_split("/\s+/",$query);
$query is the text entered from the user on the search form
$query_arr_dum is an array which is create by seperating each word on the query string (by using a space (\s) as a delimiter. This array is used later on for matching words in the pages in the site.
What I would like to do is, if someone puts a phrase in quotes, that is treated as one work.
right now if you enter
new red house // without quotes
you will get results from pages that contain the word "new" and the word "red" and the work "house" but not necessarily right next to each other.
What I want to do, is have it so if you enter
new "red house"
you will get pages that match the word "new" and the phrase "red house"
How can I make that happen?