2009/4/24 Adam Williams <awill...@mdah.state.ms.us>:
>
>
> Jan G.B. wrote:
>>
>> You could try it with regular expression matching..
>> for example:
>> <?php
>>    preg_match_all('/([a-z]+|"[a-z ]+")/i', $searchstring, $resultarray);
>> ?>
>>
>>
>> Regards
>>
>
> Thanks.  That seems to create 2 duplicate arrays, though.  Can it be
> narrowed down to just array [0]?
>
> preg_match_all('/([a-z]+|"[a-z ]+")/i', $_POST["terms"], $termsarray);
> echo $_POST["terms"]."<br>";
> print_r($termsarray);
>
> displays:
>
> John Jill "Judy Smith"
> Array ( [0] => Array ( [0] => John [1] => Jill [2] => "Judy Smith" ) [1] =>
> Array ( [0] => John [1] => Jill [2] => "Judy Smith" ) )
>

Yes, preg_match_all returns all matches and the subpattern matches
(the "stuff" inside the brakes)
You can ommit stop it by using (?:) instead of ()..
So: preg_match_all('/(?:[a-z]+|"[a-z ]+")/i', $_POST["terms"], $termsarray)

You might want to check out the regular expression manuals on
http://www.php.net/manual/en/book.pcre.php

regards

>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to