I am trying to find out what extensions a particular url has, Here is what I am trying to do:
$pathinfo = pathinfo('http://imgur.com/9P54j');
$extension = $pathinfo['extension'];
echo $extension;
The url ‘http://imgur.com/9P54j’ is actually a url having 9P54j.gif image, and its not evident in the url, how do I extract the extension .gif of the the file ‘9P54j’ ?
That URL is not a URL to the .gf image, but a page that contains the image in its HTML. You will want to parse the HTML for the URL to the image. Try: rightclick on the image in the link you provided above, and click “open image” or “view image” to see the full URL.
Even that URL may not have an extension because the data may be streamed to the user bia PHP. If that’s the case, just check the Content-Type header to find out what the extension is.