Replace words - Ignore words between brackets
<p>I'm using an ubb parser to convert several codes within brackets to html codes. I want to use a string replacer aswell to replace some unwanted words. </p>

<p>Now, I'm using this:</p>

<pre><code>foreach($f AS $value) {
            $escapeNamesArray[] = '/'.$value['woord'].'/i';
            $escapeNamesReplace[] = '&lt;span style="color: gray;"&gt;'.$value['vervanging'].'&lt;/span&gt;';
        }

        $string = preg_replace($escapeNamesArray, $escapeNamesReplace, $string);
</code></pre>

<p>When I want to replace the word "Hello" to "Hey", everything is working fine. But when I place the word "Hello" between brackets, for example:</p>

<p>[url=http://www.hello.com]kdskdsds[/url] </p>

<p>The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?</p>

<p>Thanks for your reply!</p>
