PHP利用正则表达式替换标签
$str = '你好吗,还可以吧一般般了[link url="http://www.chinanews.com/sh/2015/11-13/7621991.shtml"]义昌大桥爆炸垮塌致14死案宣判 被告人张根林死缓[/link]一点都不好怎么办啊areyouok[][link url="http://www。baidu。com"]这个正则表达式确定好使嘛[/link]are幽邃';
$string = '你好这是一个连接preg_match_all你好吗这还是几日人了';
preg_match_all('/(.*?)/i',$string,$arr);
preg_match_all('/\[link url=\"(.*?)\".*?\](.*?)\[\/link\]/i',$str,$arr);
var_dump($arr);
if($arr){
foreach($arr[0] as $ke=>$va){
$str=str_replace($va,''.$arr[2][$ke].'',$str);
}
}
echo $str;
Statement: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