I want to strip the extension from a filename, and get the file name - e.g. file.xml -> file, image.jpeg -> image, test.march.txt -> test.march, etc.
So I wrote this function
function strip_extension($filename) {
$dotpos = strrpos($filename, ".");
if ($dotpos === false) {
$result = $filename;
}
else {
$result = substr($filename,0,$dotpos);
}
return $result;
}
Which returns an empty string.
I can't see what I'm doing wrong?