How to get filename from path in php?

In this article, We’ll get the filname from the path provided.




To get the filename from path, we’ll use php’s inbuilt basename function.

basename() function in PHP is an inbuilt function which is used to return the base name of a file if the path of the file is provided as a parameter.

   $filename = basename("https://nexladder.com/blog/wp-content/uploads/2018/03/nexlogo.png");
   echo $filename; //nexlogo.png

That’s it!. Please share your thoughts or suggestions in the comments below.

Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *