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


<[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to