Re: search string
| From: | Tobias Talltorp | Date: | Sun, 15 Apr 2001 23:20:00 +0000 |
| Subject: | Re: search string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48683@lists.php.net to get a copy of this message | ||
I think you want regular expressions...
Try this on for size:
$str = "http://www.yahoo.com/somedir/somepage.html";
if (preg_match("/www.yahoo.com/i", $str)) {
print "Your submission cannot be accepted";
} else {
print "You are good";
}
If you want to read up on regular expressions:
http://www.php.net/manual/en/ref.pcre.php
(Faster than ereg)
http://www.php.net/manual/en/ref.regex.php
// Tobias Talltorp
""Joseph Bannon"" <joseph@iwebsitesoftware.com> wrote in message
news:NEBBJPFPMLBIJMIFFHFJMELHCMAA.joseph@iwebsitesoftware.com...
> What is the function to search a string? Basically, I want search a string
> (a url) to see if it has "www.yahoo.com" in it and if yes, tell the user
> their submission cannot be accepted.
>
> J
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>