Re: Re: Fuzzy Array Search

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

 




On 06/07/2011 04:28 PM, Floyd Resler wrote:
>
> Shawn,
> 	I'm terrible with regular expressions.  Could you give me an example?
>
> Thanks!
> Floyd
>
>

Depends.  Could be as simple as this to return an array of all
occurrences of $needle in any of the $haystack_array values:

$haystack_array = array('something is here', 'nothing matches here',
'there will be a somethingsomething match here');
$needle = 'something';
$matches_array = preg_grep("/$needle/", $haystack_array);

Depends on where you are getting the search criteria and how you want it
to match in the array.  BTW...  If this is originally in a database then
you can do it there with the LIKE operator and % wildcard.

-- 
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