Posted By

petrafull on 11/08/09


Tagged

php extension


Versions (?)

PHP remove file extension from string


 / Published in: PHP
 

  1. $image_name = substr(filename, 0 , -4);

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ignace on November 21, 2009

Posting things like this indicates you should be spending more time on php.net as a function for this already exists:

print pathinfo($filepath, PATHINFO_FILENAME);

Posted By: verostudios on July 13, 2010

Also it should be noted that assuming all file extensions are 3 characters long is poor practice.

example: .jpeg, .ai, .docx

You need to login to post a comment.