One to one substitution of the PHP array
the following methods can implement key words and special processing of keywords.
[code].Lt; php
header (.Quot; Content-type: text/html; charset=utf-8.quot;); $search = explode (',','/'.implode ('/ /, / /', $matches.#91; 0.#93;). '/');
/ / / / / no
if (empty ($matches.#91; 0.#93;)) return; Oreach ($replace as $key=.gt; $val) {
if (! Isset ($matches.#91; 0.#93;.#91; $key.#93;)); / / / / / / / > / > merge special replacement array and matching array. Hes.#91; 0.#93;.#91; $i.#93; = isset ($replace.#91; $i.#93;) $replace.#91; $i.#93; $matches.#91; 0.#93;.#91; >; A specific character $tmp_match
$replace = implode (',', $replace);
$replace = str_replace ($word, $tmp_match, $replace); / / / / / / temporary replacement character
$replace = = > = > > > > / > / / / / / / / / / / / / / replacement place G = preg_replace ($search, $replace, $string, 1); / / / / / / / each time only one
$string = str_replace ($tmp_match, $word, $string) in the array is replaced; > $string ='aaabaaacaaadaaa';
$word ='aaa';
$replace = array (null,'xxx','yyy'). Aaab Chinese ccaaad Chinese eee';
$word =' Chinese ';
$replace = array (null, "(replace Chinese 2)', '(replace Chinese 3)');
echo 'Original:'.$string.'.lt; output R / > Original: aaabaaacaaadaaa
output: aaabxxxcyyydaaa
Original: Chinese aaab Chinese ccaaad Chinese eee
output: Chinese aaab (replace Chinese 2) ccaaad (replace Chinese 3) eee
//*/
?.gt;.Gt;