$url ="http://yahoo.com/abcdef/2153abc.gif"; preg_match("/[^\/]+$/",$url,$matches); $file_name = $matches[0]; print "$file_name";