How to use pathinfo() to get the filename of a file without the extension (PHP)

There comes a time in a programmers life when you want or need to grab the filename of a file, but not the file extension, while using PHP.

Here’s how to do just that:

$filename = pathinfo('./bin/myimage.jpg', PATHINFO_FILENAME);
echo $filename;

It comes in handy when you want to do something with the filename without having the file extension there to get in the way. Please use responsibly.

Leave a comment

Find the Best SEO in Fort Lauderdale, Florida (Plantation SEO) | Drupal & Worpress Develpment