<?phpclass tagreplaceapi{public function Tagreplace ($content, $tags) {//replace content and all Tags$replacearr = Array (); $ Tagslength=count ($tags); for ($i =0; $i < $tagslength; $i + +) {$content = $this, Tagreplacecontent ($content, $tags [$ I], $REPLACEARR, $i);} foreach ($replaceArr as $key = + $value) {//echo "key=". $key. ", value=." $value. "<br/>"; $content = Str_replace ($key, $value, $content);} return $content;} Public Function Tagreplacecontent ($content, $tag, & $replaceArr, $i) {//replace content and tag$tagname = $tag [' TagName ']; $tagUrl = $tag [' Tagurl '];//echo "tagname=". $tagName. ", Tagurl=." $tagUrl. "<br/>", $reValue = "<a href=\" ". $tagUrl." \ ">". $tagName. " </a> "; $content = Str_replace ($reValue, $tagName, $content); $reKey =" ###### ". $i. "######"; $content = Str_replace ($tagName, $reKey, $content); $REPLACEARR [$reKey] = $reValue; return $content;}} $content = ' generally do not pay attention to millet feel normal but the millet genuine black bracelet a piece of millet genuine piston headset 2-generation coffee gold photos, but carefully observe millet genuine black bracelet will find the most is a genuine piston headset 3 generations black only passing birds, Was captured very clearly, without the slightest blur, to know that the mobile cameraThe actual imaging effect of the state object is generally not the same as millet genuine piston headset 2 generations of coffee gold, not to mention is a flying Big bird, the picture does not appear jitter, very clear, it is obvious that Millet 5 in the movement of the shooting should be very millet to force. '; $tags = Array (' tagName ' + ' genuine piston headset 2 generation coffee gold ', ' tagurl ' = ' http://www.mi.com/kfj/'), Array (' tagName ' = ' genuine piston headphones 3 generation black ', ' tagurl ' = ' http://www.mi.com/hei/'), Array (' tagName ' = ' millet ', ' tagurl ' = ' http://www.mi.com ') /'); $tagReplaceApi = new Tagreplaceapi (); $content = $tagReplaceApi, Tagreplace ($content, $tags); Echo $content; echo "<br/>", echo "<br/>"; $content = $tagReplaceApi-Tagreplace ($content, $tags); echo $content; echo "& Lt;br/> "; echo" <br/> "; $content = Tagreplace ($content, $tags), $tagReplaceApi, Echo $content; >