Page 1 of 1

deleting file extensions

Posted: Thu Feb 05, 2004 11:20 pm
by decoy1
Hi,

Could anyone show me how to delete the extension off a file? This is the little bit I have now...

Code: Select all

while(false !== ($file = readdir($dir)))
{
  $sep = explode('.', $file);
  //$num = count($sep);
  //$ext = $split[$num - 1];
  foreach($sep as $key => $value)
  {
    echo $value. '<br>';
  }
}
As you can see, I can blow the file name up and isolate the extension but not sure what to do next. I can't believe I'm not thinking of a way to do it. Am I approaching this correctly, or should I be using some sort of regular expression, or what? Thanks in advance for any advice.

Rob

Posted: Thu Feb 05, 2004 11:22 pm
by John Cartwright
Do you mean you are displaying the file and you wish to hide the file extensions? OR do you mean actually delete the extensions ( dont see the point in this )

If it is the first one, why dont you try looking 1 sec in the forums and check out this thread

viewtopic.php?t=17664

Posted: Thu Feb 05, 2004 11:31 pm
by decoy1
Hi,

sorry...it isn't necessary to actually delete them, just not display them.

thanks

Posted: Thu Feb 05, 2004 11:55 pm
by decoy1
I just now saw your link to the other thread... I just needed someone to smack me in the back of the head and wake me up.

Appreciate the help