The article linked above provides the regexp pattern for validating an URL, so you can use a function such as [man]preg_match/man to make sure the URL given matches the pattern. If it doesn't, it's not valid.
Next, use [man]basename[/man] to get the filename part of the URL. Now that you have the filename, it's simply a matter of using [man]explode/man to explode the string on the period(s), and look at the last element in the array. In case you don't know how to do this, here's an example of using explode and accessing the last element of an array:
$path = 'http://www.thisisatest.com/images/my.test.image.jpeg';
$filename_array = explode('.', basename($path) );
echo $filename_array[(count($filename_array)-1)]; // echo's 'jpeg'