I have several strings that will be replaced with the same string...
ie
$text=str_ireplace('[/VIDEO]','</div>',$text);
$text=str_ireplace('[/ARTICLE]','</div>',$text);
$text=str_ireplace('[/IMG]','</div>',$text);
anyway to use an array in lieu of the initial string value?
Yes. See the documentation for str_ireplace
:
If search and replace are arrays, then str_ireplace() takes a value from each array and uses them to do search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values. If search is an array and replace is a string, then this replacement string is used for every value of search.
$text=str_ireplace(array('[/VIDEO]', '[/ARTICLE]', '[/IMG]'),'</div>',$text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With