Possible Duplicate:
How remove extension from string (only real extension!)
I am brand new to php and have a lot to learn! I'm experimenting with MiniGal Nano for our King County Iris Society website. It work quite well for our purposes with one small exception: the photo file name needs to be visible under the thumbnail. I've created a work around, but it shows the extension. I've found code samples of functions but have no idea how to incorporate them into the existing code. Any assistance would be greatly appreciated.
Example link: http://www.kcis.org/kcisphotogallery.php?dir=Iris.Japanese
Many thanks!
There are a few ways to do it, but i think one of the quicker ways is the following
Another solution is this. I haven't tested it, but it looks like it should work for multiple periods in a filename
Also:
In all of these,
$name
contains the filename without the extensionIf you know for certain that the file extension is always going to be four characters long (e.g. ".jpg"), you can simply use
substr()
where you output the filename:If there's a chance that there will be images with more or less characters in the file extension (e.g. ".jpeg"), you will need to find out where the last period is. Since you're outputting the filename from the first character, that period's position can be used to indicate the number of characters you want to display:
For information about these functions, check out the PHP manual at http://php.net/substr and http://php.net/strrpos.
You can use
pathinfo()
for that.