Page 2 of 2

Posted: Fri Aug 04, 2006 4:03 am
by Jenk
stripos will be even quicker. (php5)

Code: Select all

if (stripos('google', $var) !== false) {
  //'google' is in $var
}

Posted: Fri Aug 04, 2006 7:03 am
by Ollie Saunders
The problem with that is you could have a url like this:

Code: Select all

http://www.site.com/review.php?ofSite=google
That's why the regex I posted is better.
I didn't test it though, probably should have, I rarely get regexes right first time ¬_¬

Thanks for the ton of advice

Posted: Fri Aug 04, 2006 7:21 am
by fatman
My server just went PHP5, so stripos is interesting. I will try that as soon as I get back to the office.

Point taken with interest Ole, how does the regex you posted avoid me from running into a problem with the URL you show?
(Had to fiddle with it, my server didn't like it)

Posted: Fri Aug 04, 2006 8:24 am
by Ollie Saunders
Well it checks that google appears directly after http:// or http://www. not just anywhere in the string.

Aaaah!

Posted: Fri Aug 04, 2006 9:24 am
by fatman
Sometimes, if I look, I will see.

Yes, thats perfect