PHP web page tag tag replacement unit test code

巴扎黑
Release: 2023-03-03 12:12:01
Original
1223 people have browsed it

 tagReplaceContent($content, $tags[$i], $replaceArr, $i); } foreach($replaceArr as $key=>$value) { //echo "Key=" . $key . ", Value=" . $value . "
"; $content = str_replace($key, $value, $content); } return $content; } public function tagReplaceContent($content, $tag, &$replaceArr, $i){//替换内容及tag $tagName = $tag['tagName']; $tagUrl = $tag['tagUrl']; //echo "tagName=" . $tagName . ", tagUrl=" . $tagUrl . "
"; $reValue = "".$tagName.""; $content = str_replace($reValue, $tagName, $content); $reKey = "######" . $i . "######"; $content = str_replace($tagName, $reKey, $content); $replaceArr[$reKey] = $reValue; return $content; } } $content = '一般不注意小米觉得再正常不过的小米正品黑色手环一张小米正品活塞耳机2代咖啡金色照片,不过仔细观察小米正品黑色手环会发现最令人小米惊叹的是一小米正品活塞耳机3代黑色只正在经过的飞鸟,被十分清晰地抓拍了下来,没有丝毫模糊,要知道手机拍摄动态物体的实际成像效果一般都不怎么理小米正品活塞耳机2代咖啡金色想的,更何况是一只正在飞翔的大鸟,画面并没有出现抖动情况,很清晰,由此可见小米5在运动抓拍方面应该很小米给力。'; $tags = array(array('tagName' => '小米正品活塞耳机2代咖啡金色','tagUrl' => 'http://www.mi.com/kfj/'), array('tagName' => '小米正品活塞耳机3代黑色','tagUrl' => 'http://www.mi.com/hei/'), array('tagName' => '小米','tagUrl' => 'http://www.mi.com/')); $tagReplaceApi = new TagReplaceApi(); $content = $tagReplaceApi -> tagReplace($content, $tags); echo $content; echo "
"; echo "
"; $content = $tagReplaceApi -> tagReplace($content, $tags); echo $content; echo "
"; echo "
"; $content = $tagReplaceApi -> tagReplace($content, $tags); echo $content; ?>
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!