0

I am trying to get the title of a file into a string WITHOUT the extension. I understand how end() works... but i want the FRONT of the string removed. I can't find something in the PHP manual that directs me into the right direction. ANY help will be appreciated.

Example:

$fileName = $_FILES["video"]["name"];
The file name $fileType = explode('.',$fileName);
$fileType = end($fileType);
$origFileName = "<(??????)>"

found my problem. added:

$fileOrigName = basename($fileName,$fileType);
$fileOrigName = substr($fileOrigName, 0, -1);

TY for all your comments and help :)

James Walker
  • 390
  • 4
  • 19
  • if you do explode the file name on dot you can then easily get the last portion to have the extension – Goikiu Jun 15 '15 at 13:56
  • i know the file extension. i want to REMOVE the extension from the string and rename it – James Walker Jun 15 '15 at 13:58
  • possible duplicate of [PHP, get file name without file extension](http://stackoverflow.com/questions/2183486/php-get-file-name-without-file-extension) –  Jun 15 '15 at 13:59
  • TY... that was the rigt direction i was looking at @caCtus – James Walker Jun 15 '15 at 14:30

1 Answers1

2

Have a look at basename. It does exactly what you want.

Damien Pirsy
  • 25,319
  • 8
  • 70
  • 77
joconja
  • 361
  • 1
  • 5