NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regular expression for Google-like search

Flavio daCosta nyphp at n0p.net
Mon Oct 10 16:33:54 EDT 2005


How about:

$search_string = '"the color purple" movie soundtrack';
$search_terms = array();
$search_terms = preg_match_all ('/"[^"]+"|\w+/', $search_string, $matches);

print_r ($matches);


Array
(
    [0] => Array
        (
            [0] => "the color purple"
            [1] => movie
            [2] => soundtrack
        )

)



More information about the talk mailing list