PHP, get file name without file extension -


I have this PHP code:

  function ShowFileExtension ($ file path) {preg_match ('/ [^?] * /', $ File path, $ match); $ String = $ matches [0]; $ Pattern = preg_split ('/ ../', $ string, -1, PREG_SPLIT_OFFSET_CAPTURE); If (Count ($ pattern)> 1) {$ filenamepart = $ pattern [count ($ pattern) -1] [0]; Preg_match ('/ [^?] * /', $ Filenamepart, $ matches); Return Stroller ($ matches [0]); }}  

If I have a file named my.zip , then this function returns .zip .

I want to reverse, I want to return the function without my extensions.

The file is a string in only one variable.

No need for everyone

prefix = pathinfo ('/ Www / htdocs / index.html')

Example from the manual:); $ Path_parts ['dirname'] echo, "\ n"; Echo $ path_parse ['basename'], "\ n"; Replace $ Path_parts ['Extension'], "\ n"; $ Path_parts ['filename'], "\ n"; // File name is only after PHP 5.2.0

code output:

  / www / htdocs index.html html index  

And alternatively, you can get only a few parts:

  echo Pathinfo ('/ www / htdocs / index.html', PATHINFO_EXTENSION); // output HTML  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -