我想使用preg_replace结合'[',']'和'/',但我无法找到正确的方法!preg_replace和组合'[',']'和'/'替换
我有这些字符串:
$str = "This is a [u]PHP[/u] test . This is second[/u] test.
This [u]is another [u]test[/u].";
$url = "http://www.test.com";
在结果我想有:
str1 = "This is a <a href='http://www.test.com'>PHP</a> test .
This is second[/u] test.
This <a href='http://www.test.com'>is another [u]test</a>.";
并且还[U] = [U],[/ U] = [/ U]是不区分大小写。
您无法使用preg_replace来平衡标签。 – 2012-02-15 11:22:36
...不仅仅带有'preg_replace'。 – Gumbo 2012-02-15 11:26:51