PHP uses regular expressions to replace tags
$str = 'How are you? It's okay. It's just so-so. [link url="http://www.chinanews.com/sh/2015/11-13/7621991.shtml"] Yichang Bridge exploded and collapsed, killing 14 The case was sentenced to a suspended death sentence for the defendant Zhang Genlin[/link] It’s not good at all. What should I do? areyouok[][link url="http://www.baidu.com"]Is this regular expression sure to work[/link]areyousui ';
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){
}
}
echo $str;
http://www.bkjia.com/PHPjc/1071280.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1071280.htmlTechArticlePHP uses regular expressions to replace tags $str = How are you? It’s ok. Just so-so [link url= http://www.chinanews.com/sh/2015/11-13/7621991.shtml] The verdict was announced in the case of Yichang Bridge explosion and collapse that killed 14 people...
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