Hi there, what you’re trying to do could be achieved with a built-in PHP function.
Check out this article:
http://stackoverflow.com/questions/173868/how-to-extract-a-file-extension-in-php
You would declare a variable to use as the file extension. Something like:
$ext = pathinfo($url, PATHINFO_EXTENSION);
Reference: http://php.net/manual/en/function.pathinfo.php