[thelist] get filename before the extension (php)

Paul Bennett Paul.Bennett at wcc.govt.nz
Thu Feb 1 14:47:17 CST 2007

Hi Mark,

Do you have control over the filenames? Can you guarantee that the filename won't have more than one full stop / period?

If so then using explode('.', $filename);
Will give you an array like:

	0 => '/my/path/to/filename'
	1 => 'txt'

If there is more then one full stop / period, a regexp will be your best bet and my regexp kung-fu isn't too flash :)

Also, it looks like your original system is appending the extra '.txt' to the filename without first checking if it already has the extension...


More information about the thelist mailing list