Re: string

From: Date: Mon, 07 Apr 2008 14:23:48 +0000
Subject: Re: string
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-272624@lists.php.net to get a copy of this message
Excellent. Thanks all! John Daniel Brown wrote:
On Mon, Apr 7, 2008 at 9:25 AM, John Taylor-Johnston <jt.johnston@usherbrooke.ca> wrote:
$name = "John Taylor"; I want to verify if $name contains "john", if yes echo "found"; Cannot remember which to use: http://ca.php.net/manual/en/ref.strings.php Sorry, John
    
<?php if(stristr($name,'john')) {
    // True
} ?>
    Since you said you wanted to know if it "contains 'john'", this
will find if 'john' (insensitive) matches any part of the name. So in your case, it would match on both John and Johnston.


« previous php.general (#272624) next »