Re: string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 7, 2008 at 9:25 AM, John Taylor-Johnston
<jt.johnston@xxxxxxxxxxxxxx> 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.

-- 
</Daniel P. Brown>
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux