Created
September 19, 2014 05:16
-
-
Save marceux/def4087b41ae518d4927 to your computer and use it in GitHub Desktop.
gfyCat gfyName Grabber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function for grabbing the gfyName from a gfyCat link... | |
*/ | |
function grabGfyName ($url) { | |
$pattern = '/((https?:)?\/\/)?(.+?\.)?gfycat\.com\/(.+)/'; | |
$matches = array(); | |
preg_match ($pattern, $url, $matches); | |
return $matches[4]; | |
} | |
$gfyUrls = array( | |
'http://www.gfycat.com/AngryHatefulAsianconstablebutterfly', | |
'http://gfycat.com/AngryHatefulAsianconstablebutterfly', | |
'https://fast.gfycat.com/AngryHatefulAsianconstablebutterfly', | |
'https://gfycat.com/AngryHatefulAsianconstablebutterfly', | |
'http://demo.gfycat.com/AngryHatefulAsianconstablebutterfly', | |
'https://center2.gfycat.com/AngryHatefulAsianconstablebutterfly ' | |
); | |
foreach ($gfyUrls as $url) { | |
echo grabGfyName($url) . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment