Ok here goes. This is a short snippit which will give you the file name at the end of the URL. The snippint uses the pathinfo function. I might make it a function in a few days.
<?php
$url = "enter a url here";
$path_parts = pathinfo($url);
$FileName = "".$path_parts['filename'].".".$path_parts['extension']."";
print "$FileName";
?>