title: PHP - stripping the extension from a file name string
body: <p>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.</p>
  
  <p>So I wrote this function</p>
  
  <pre><code>function strip_extension($filename) {
     $dotpos = strrpos($filename, ".");
     if ($dotpos === false) {
        $result = $filename;
     }
     else {
        $result = substr($filename,0,$dotpos);
     }
     return $result;
  }
  </code></pre>
  
  <p>Which returns an empty string.</p>
  
  <p>I can't see what I'm doing wrong?</p>