title: preg_replace The /e modifier is deprecated using arrays as pattern and replacement
body: <p>I used to have this block of code to simulate some sort of BBCode:</p>
  
  <pre><code>$pattern = array(
      '/\\n/',
      '/\\r/',
      '/\[list\](.*?)\[\/list\]/ise',
      '/\[b\](.*?)\[\/b\]/is',
      '/\[strong\](.*?)\[\/strong\]/is',
      '/\[i\](.*?)\[\/i\]/is',
      '/\[u\](.*?)\[\/u\]/is',
      '/\[s\](.*?)\[\/s\]/is',
      '/\[del\](.*?)\[\/del\]/is',
      '/\[url=(.*?)\](.*?)\[\/url\]/ise',
      '/\[email=(.*?)\](.*?)\[\/email\]/is',
      '/\[img](.*?)\[\/img\]/ise',
      '/\[color=(.*?)\](.*?)\[\/color\]/is',
      '/\[font=(.*?)\](.*?)\[\/font\]/ise',
      '/\[bg=(.*?)\](.*?)\[\/bg\]/ise',
      '/\[size=(.*?)\](.*?)\[\/size\]/ise'
  );
  
  $replace = array(
      '&lt;br/&gt;',
      '',
      '$this-&gt;sList(\'\\1\')',
      '&lt;b&gt;\1&lt;/b&gt;',
      '&lt;strong&gt;\1&lt;/strong&gt;',
      '&lt;i&gt;\1&lt;/i&gt;',
      '&lt;span style="text-decoration: underline;"&gt;\1&lt;/span&gt;',
      '&lt;span style="text-decoration: line-through;"&gt;\1&lt;/span&gt;',
      '&lt;span style="text-decoration: line-through;"&gt;\1&lt;/span&gt;',
      '$this-&gt;urlfix(\'\\1\',\'\\2\')',
      '&lt;a href="mailto:\1" title="\1"&gt;\2&lt;/a&gt;',
      '$this-&gt;imagefix(\'\\1\')',
      '&lt;span style="color: \1;"&gt;\2&lt;/span&gt;',
      '$this-&gt;fontfix(\'\\1\',\'\\2\')',
      '$this-&gt;bgfix(\'\\1\',\'\\2\')',
      '$this-&gt;sizefix(\'\\1\',\'\\2\')'
  );
  
  return preg_replace($pattern, $replace, nl2br(stripslashes($string)));
  </code></pre>
  
  <p>But I'm moving to PHP 5.5 and I'm getting errors here, it used to work perfectly, this is the erros I'm getting:</p>
  
  <blockquote>
    <p>Deprecated: preg_replace(): The /e modifier is deprecated, use
    preg_replace_callback instead in</p>
  </blockquote>
  
  <p>I tried several stuff but nothing worked so far.</p>
  
  <p>This is the code I tried so far:</p>
  
  <pre><code>return preg_replace_callback(
      $pattern,
      function($matches) use ($replace) {
          return ((isset($replace[$matches[0]])) ? $replace[$matches[0]] : '');
      },
      nl2br(stripslashes($string))
  );
  </code></pre>
  
  <p>I have been reading around but most examples are related to basic replacements, here I have two arrays.</p>
  
  <p>Please <strong>notice</strong> that there are some methods that are being called from the $replace area.</p>
  
  <p>How can I solve this? Is this the right approach?</p>