I'm passing through a variety of URLs in a global variable called target_passthrough, so the URL of a page might look like: http://www.mysite.com/index.php?target_passthrough=example.com
Or something like that. Formats for that variable may be a variety of things such as (minus quotes):
- "www.example.com"
- ".example.com"
- "example.com"
- "http://www.example.com"
- ".example.com/subdir/"
- ".example.com/subdir/page.php"
- "example.com/subdir/page.php"
Please note how some of those have periods as the first character such as 2,5, and 6.
Now, what I am trying to do is pull out just "example.com" from any of those possible scenarios with PHP and store it to a variable to echo out later. I tried parse_url but it gives me the "www" when that is present, which I do not want. In instances where the url is just "example.com" it returns a null value.
I don't really know how to do regex matching or if that is even what I need so any guidance would be appreciated--not really that advanced at php.