How remove extension from string (only real extension!)
<p>I'm looking for a small function that allow me to remove the extension from a filename.</p>

<p>I found many examples by googling, but they are bad, because they just remove part of the string with "." . They use dot for limiter and just cut string.</p>

<p>Look at these scripts,</p>

<pre><code>$from = preg_replace('/\.[^.]+$/','',$from);
</code></pre>

<p>or</p>

<pre><code> $from=substr($from, 0, (strlen ($from)) - (strlen (strrchr($filename,'.'))));
</code></pre>

<p>When we add the string like this:</p>

<blockquote>
  <p>This.is example of somestring</p>
</blockquote>

<p>It will return only "This"...</p>

<p>The extension can have 3 or 4 characters, so we have to check if dot is on 4 or 5 position, and then remove it.</p>

<p>How can it be done?</p>
