PHP, what is the best choice to remove a known string?

I am looking to find and replace a known string from another string. Should I use str_replace () or preg_replace ()? The string that needs to be replaced will look like [+qStr+], [+bqID+]or [+aID+], and it will be searched for in a piece of code like 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 replace the rows with the results of a MySQL query and perform this action or the like up to 200 times at a time. Which function str_replace () or preg_replace () will be the easiest and / or fastest way.

+5
source share
3 answers

​​ , str_replace, . , , ereg_replace preg_replace, .

+8

, str_replace(). , .

PS: preg_replace() ereg_replace(), ...

+2

ereg_replace() PHP 5.3.0, .

str_replace() preg_replace() . str_replace() /; preg_replace - ,

0

All Articles