Thanks!
Your first appraoch seems to make clearer sense for me.
Great pinch hit,
John
Paul Novitski wrote:
If you're splitting your search string into discrete words, most
search engine logic doesn't require quotes. Typically, quotation
marks combine multiple words into single expressions, which makes
sense with "John Johnston" but not with "John" "Johnston".
But since you requested the quotes I'll include them:
Here's one way to convert an incoming word series for a search:
// get the entered text
$sEnquiry = $_GET["searchenquiry"];
RESULT: [ john johnston ]
// protect against input attacks here
...
// remove whitespace from beginning & end
$sEnquiry = trim($sEnquiry);
RESULT: [john johnston]
// replace internal whitespace with single spaces
$sEnquiry = preg_replace("/\s+/", " ", $sEnquiry);
RESULT: [john johnston]
// replace each space with quote-space-plus-quote
$sEnquiry = str_replace(" ", "\" +\"", $sEnquiry);
RESULT: [john" +"johnston]
// add beginning & ending delimiters
$sEnquiry = "+\"" . $sEnquiry . "\"";
RESULT: [+"john" +"johnston"]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php