Looking for a better way to handle this growing array used for preg_replace first time visiting Code Review.  I figured this was a more appropriate spot than SO for this question.   Here goes...

Currently, I have a php function that converts bbcode format text in to HTML (among other things).   A code snippet is as follows...

function bbcode_format ($str) {  

 $simple_search = array( 
    '/\[b\](.*?)\[\/b\]/is',  // bold
    '/\[i\](.*?)\[\/i\]/is',  // italics
    '/\[u\](.*?)\[\/u\]/is',  // underline
)

  $simple_replace = array(  
    '&lt;strong&gt;$1&lt;/strong&gt;',  
    '&lt;em&gt;$1&lt;/em&gt;',  
    '&lt;u&gt;$1&lt;/u&gt;'
)

    $str = preg_replace ($simple_search, $simple_replace, $str);  
    return $str;
}


The code itself works fine.   However, in my actual code, there are currently around 60 items in each array I'm checking for, as I also used it to convert smileys, for example.   

My concern is that this approach doesn't seem to be scalable, at least in the sense that the array just keeps growing and growing.   

I'm wondering if anyone has another approach as to how this might be done, or any suggestions to improve my current method.   Thanks!

Additional Info

Thanks for the suggestions so far...   I may not have used the best examples above, as b / i / u are only a small set of what I'm replacing.    I probably have more "smiley" replacements, than anything, so those generally look like this...

'/:\)/is',          // smiley :)
'/:d/is',           // laugh smiley :D
'/\:gift1\:/is',    // Holiday Gift 1 :gift1:
'/\:gift2\:/is',    // Holiday Gift 2 :gift2:


Each of those is then replaced with an  tag.
You have two issues: how to represent all of the desired transformations as code, and how to perform the substitutions efficiently.

To address the data representation issue — you want to use an associative array.

$simple_replacement_patterns = array(
    '/\[b\](.*?)\[\/b\]/is' =&gt; '&lt;strong&gt;$1&lt;/strong&gt;',
    '/\[i\](.*?)\[\/i\]/is' =&gt; '&lt;em&gt;$1&lt;/em&gt;',
    '/\[u\](.*?)\[\/u\]/is' =&gt; '&lt;u&gt;$1&lt;/u&gt;',
);


However, there is a lot of redundancy there, which violates the Don't Repeat Yourself principle.  Ideally, your source code should contain just

$simple_tag_translations = array(
    'b' =&gt; 'strong',
    'i' =&gt; 'em',
    'u' =&gt; 'u',
);


… and the computer build $simple_replacement_patterns for you.

Consider mapping [b]bold text[/b] to &lt;b&gt;bold text&lt;/b&gt;, [i]italic text[/i] to &lt;i&gt;italic text&lt;/i&gt;, and [u]underlined text[/u] to &lt;u&gt;underlined text&lt;/u&gt;.  Not only would the mapping be trivial (BBCode is inspired by HTML designed to be easily translated, after all), you would also not be inferring semantic value into the style.  For example, maybe the BBCode text was italicized because it is a title in a bibliography entry, not because it is to be emphasized.