php正则表达式处理html循环嵌套的代码替换

<?php

$str = ‘<P align=left><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <STRONG><FONT color=red><STRONG><FONT color=red>《阿斯顿发生大幅</FONT></STRONG>点击进入</FONT></STRONG></STRONG></P><STRONG>11111212121</STRONG>’;

$source=”/<STRONG>(.*?)<\/STRONG>/”;
$taget='[B]$1[\B]’;
$searchstr='<STRONG>’;
while(strpos($str,$searchstr))
 $str = preg_replace($source, $taget, $str);

$str=str_replace(‘&nbsp;’,’ ‘,$str);

echo $str;
?>

Published by

admin

互联网web开发管理

Comments are closed.