$a="[table align=left width=100%]……[/table]
[table]……[/table]";
$a=str_replace("[","<",$a);
$a=str_replace("]",">",$a);
$a=str_replace("[/","</",$a);
echo $a;
显示
<table align=left width=100%>……</table>
<table>……</table>
[table]……[/table]";
$a=str_replace("[","<",$a);
$a=str_replace("]",">",$a);
$a=str_replace("[/","</",$a);
echo $a;
显示
<table align=left width=100%>……</table>
<table>……</table>
[table]……[/table]";$pat[] = "/\[table(.*)\](.+)\[\/table\]/";
$rpl[] = "<table\\1>\\2</table>";$joketext = preg_replace($pat, $rpl, $str);
echo $joketext;\\1、\\2、\\3...分别对应正则表达式中“()”的出现
另外,为什么开始结束要加上/呢?