PHP, what is the better choice for removing a known string?

Posted by Brook Julias on Stack Overflow See other posts from Stack Overflow or by Brook Julias
Published on 2010-06-14T14:49:43Z Indexed on 2010/06/14 14:52 UTC
Read the original article Hit count: 264

Filed under:
|
|

I am looking to search for and replace a known string from within another string. Should I use str_replace() or ereg_replace()? The string to be replaced would be something similar to [+qStr+], [+bqID+], or [+aID+] and it would be being searched for in a code chunk similar to this:

<li> [+qStr+]
   <ol class="mcAlpha">
       <li><input type="radio" name="[+bqID+]" id="[+bqID+]_[+aID+]" value="[+aID+]" /><label for="[+bqID+]_[+aID+]">[+aStr+]</label></li>
   </ol>
</li>

I would be replacing the strings with the results from a MySQL query, and be performing this action or similar up to 200 times at a time. Which function str_replace() or ereg_replace() would be the easiest and/or quickest method to take.

© Stack Overflow or respective owner

Related posts about php

Related posts about regex