RE: [PHP] search question
| From: | Bryan Koschmann - GKT | Date: | Wed, 27 Nov 2002 21:54:11 +0000 |
| Subject: | RE: [PHP] search question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126367@lists.php.net to get a copy of this message | ||
On Wed, 27 Nov 2002 Liam.Gibbs@dfait-maeci.gc.ca wrote:
|You could try any number of PHP functions, but the best ones would be
|strchr/strstr/stristr (for locating the first occurrence of the string),
|strpos (find the position of the first occurrence), or strrchr (to find the
|last).
|
I was just using something like below. Seems to work to find the string
anywhere in the name. Am I missing something or is it really that simple?
Bryan
<?php
$name = "John Smith";
$search = "smi";
if (eregi("$search", $name)) {
echo "$search is in $name\n";
} else {
echo "$search is NOT in $name\n";
}
?>