Re: Faking Boolean

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux