SPLFileInfo: get filename without extension

后端 未结 2 2148
悲哀的现实
悲哀的现实 2021-02-13 07:23

I\'m accessing a number of files in the SPLFileInfo object. I see a way to get the path, filename, and even extension of the file. Is there a way to get the filename without ext

2条回答
  •  囚心锁ツ
    2021-02-13 07:27

    I couldnt find anything official like the .net's - Path.GetFileNameWithoutExtension https://msdn.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension%28v=vs.110%29.aspx

    Here is what I'm using instead preg_replace("/.[^.]+$/", "", $file->getBasename());

    I've tested it with "file.txt.zip" to make sure it returns "file.txt", not "file"

提交回复
热议问题