1

I need to get the name of the file from url

$url = 'http://p1.pichost.me/i/53/1770973.jpg'

$fileName = getFileName($url);

is there some php function to do this

Hitesh
  • 3,882
  • 10
  • 40
  • 81

1 Answers1

4

You can use basename() in this case:

$url = 'http://p1.pichost.me/i/53/1770973.jpg';
$filename = basename($url);
echo $filename; // 1770973.jpg
Kevin
  • 41,329
  • 12
  • 52
  • 68