php-db | 2001072
Date: 07/26/01
- Next message: Brian Weisenthal: "[PHP-DB] porting from ms sql to mysql"
- Previous message: phpnet <email protected>: "[PHP-DB] (preg_match ?"
- In reply to: phpnet <email protected>: "[PHP-DB] (preg_match ?"
- Next in thread: CC Zona: "[PHP-DB] Re: (preg_match ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This works only if the list is space delimited because of the \b:
$search = "TheName";
$data = "TheName TheAddress ThePhone";
if (preg_match("/\b$search\b/i", $data))
{ echo "True<br>"; }
else { echo "False<br>"; }
However as your list is now this works:
$search = "TheName";
$data = "TheName,TheAddress,ThePhone";
if (preg_match("/$search/i", $data))
{ echo "True<br>"; }
else { echo "False<br>"; }
-- phill<phpnet <email protected>> wrote in message news:3B60AC492BC.DF36PHPNET <email protected> > What's wrong with this use of preg_match? > > $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. > Thanks > Dave
-- 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>
- Next message: Brian Weisenthal: "[PHP-DB] porting from ms sql to mysql"
- Previous message: phpnet <email protected>: "[PHP-DB] (preg_match ?"
- In reply to: phpnet <email protected>: "[PHP-DB] (preg_match ?"
- Next in thread: CC Zona: "[PHP-DB] Re: (preg_match ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

