substr not working correctly?
<p>I am creating a forum, and currently working on the bbCode section. All the BBCode works, but I am also implementing an emoticon system. The syntax looks like this: [e]:)[/e]</p>

<p>I made this string for testing purposes:</p>

<pre><code>[b]hello world[/b] [i]i am having fun[/i] [e]:)[/e] how are you doing today?! &lt;3[color=blue]:D[/color]
</code></pre>

<p>And it is returning something that is not what I want. Here is what it is returning:</p>

<pre><code>:)[/e] how are you doing today?! &lt;3[color=bl
</code></pre>

<p>This is my code:</p>

<pre><code>function bbCode($str) {
     if (strpos($str, '[e]')!==false &amp;&amp; strpos($str, '[/e]')!==false) {
          $f = strpos($str, '[e]') + 3;
          $s = strpos($str, '[/e]');
          $emote = substr($str, $f, $s);
     }
     return $emote;
}
</code></pre>

<p>Note that $f and $s are returning the correct positions, 45 and 47, but the substr is not cutting my string correctly. Why is this and how can I fix it?</p>
