Consider the following list of URLs:
1 http://www.cnn.com/international/stories/423423532
2 http://www.traderscreener.com/blah
3 http://is.gd/fsdaGdfd3
4 http://goo.gl/23V534
5 http://bit.ly/54HFD
6 http://stackoverflow.com/question/ask
I would like to expand shortened URLs to their original form:
$headers = get_headers($URL, 1);
if (!empty($headers['Location'])) {
$headers['Location'] = (array) $headers['Location'];
$URL = array_pop($headers['Location']);
}
However, I need to match all URLs against an array of shortening services:
$array(
'is.gd', 'bit.ly', 'goo.gl', 'wibi.us', 'tinyurl.com' // etc
)
In this case, this would have to filter out URLs 3, 4, and 5. I believe the most easy way of doing this would be to grab ***
in http://***/blah
. Since I have little experience using regex, what would be the regex needed? Or is there a better way of approaching this?