-1

Possible Duplicate:
How remove extension from string (only real extension!)
Remove file extension on file upload

I am looking for ways to remove extensions but from what i found in google are really bad examples on how to do it.

 $from = preg_replace('/\.[^.]+$/','',$from);

Something like this, any idea on how to do it?

Community
  • 1
  • 1
apple
  • 13
  • 3

1 Answers1

1

Check out the basename function, which should do that for you. Note that it will also strip any folder names in the path.

Avner Shahar-Kashtan
  • 14,492
  • 3
  • 37
  • 63
  • No, it won't. basename() only presents him with the filename and extension. – nand Feb 12 '12 at 19:05
  • I didn't understand your comment. `basename` will strip out the path and the extension and leave the base filename. That's what the OP asked for, if I understood correctly. – Avner Shahar-Kashtan Feb 12 '12 at 19:07