Re: (preg_match ?

From: Date: Fri, 27 Jul 2001 10:20:45 +0000
Subject: Re: (preg_match ?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10828@lists.php.net to get a copy of this message
In article <3B60AC492BC.DF36PHPNET@192.168.1.6>, phpnet@SeaPort6.com 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

« previous php.db (#10828) next »