I have an array that contains several domain names. I need to replace those domains inside block开发者_如何学运维s of text (forum posts) with another string, if any of them actually appear inside that forum post.
Whats the best way of doing that? I can't alter the array that contains a list of domains it would search for. Its stored as follows:
$domain_list = array("domain1.com", "domain2.com", "domain3.com");
Try with str_replace
http://www.php.net/manual/en/function.str-replace.php
$modified_haystack = str_replace($domain_list, $repl, $haystack);
$repl
is the replacement text, $haystack
is the text to search.
精彩评论