-1

I have a script I wrote to scan several websites for a google link to make sure it is there. For some reason my script is not working. When I check it at http://www.regexr.com/, it works, but not in live implementation.

example of a link its supposed to find:

https://plus.google.com/+VincentsHeatingPlumbingIncPortHuronTownship/about?hl=en

preg_match I am using:

if (preg_match_all("/(.*)plus.google.com(.*)/", $attributeValue->value)) 
{ 
  $googleLinkCount ++;
  $googleLinkHrefs[] = $attributeValue->value;
}
David Webb
  • 253
  • 4
  • 18

1 Answers1

4

Don't use a regular expression, use parse_url:

if (parse_url($attributeValue->value, PHP_URL_HOST) === 'plus.google.com') {
    // host is plus.google.com
}
Tom Fenech
  • 72,334
  • 12
  • 107
  • 141