php-db | 2001072

[PHP-DB] Re: (preg_match ? From: CC Zona (cczona <email protected>)
Date: 07/27/01

In article <3B60AC492BC.DF36PHPNET <email protected>>, phpnet <email protected>
wrote:

> $search = "TheName"
> $data = "TheName,TheAddress,ThePhone"
>
> if (preg_match('"/\b'.$search.'\b/i"', $data))
> {
> echo "True<br>";
> }
> else
> {
> echo "False<br>";
> }
> I am trying to see if the search name matches exactly a name in the $data.

In that case, may I suggest an alternative method?

$arr=explode(",",lower($data));
if(in_array(lower($search),$arr)))
  ...

(If you want to use the preg_*: take out the double quotes in your regex,
which do not appear to be delimiting the substrings within variable $data.)

-- 
CC

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>