3
Contributors
2
Replies
8
Views
10 Years
Discussion Span
Last Post by digital-ether
0

preg_match sounds like what you want.

More info can be found here:
http://us2.php.net/manual/en/function.preg-match.php

Good luck!

You can use preg_match if you're going to search for a pattern in a string.

However, if you're going to look for just a string, then you should use a function such as strstr() or stristr()

eg: case sensitive

if (strstr('http://example.com/sports.ext', 'sports')) {
   echo 'found';
} else {
   echo 'not found';
}

preg_match() is much slower than strstr() and also uses more resources as it matches a pattern.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.