$str = 'This is a [a href=xxx]test ![/a],  show photos , now [img href=xxx]';//把上面的替换成下面的 ,  也就是替换掉[a][b][img]类型的标签$str = '<b>This is a <a href="xxx">test !</a></b>,  show photos , now <img href="xxx" />';

解决方案 »

  1.   

    $str = "This is a [a href=xxx]test ![/a], show photos, now [img href=xxx]";
    $b=ereh_replace("[","<",$str);
    $a=ereg_replace("]",">",$b);
    echo $a;
      

  2.   


    没你说那么简单吧,如果单独一个[a]都被你替换了成<a>了
      

  3.   

    他只是说把那个字符串的[]改成<>嘛
      

  4.   


    $str = 'This is a [a href=xxx]test ![/a],  show photos , now [img href=xxx]';
    $str = preg_replace('|\[([^]]*)\]|', '<$1>', $str); 
    echo $str;
      

  5.   


    $str = 'This is a [a href=xxx]test ![/a],  show photos , now [img href=xxx]';
    preg_replace("/\[([^\]]+?)((=)(.*?))?\]/","<$1$3\"$4\"",$str);
    echo $str;
      

  6.   

    如果是这样,把[/a][a]都改掉了, 条件是要符合, [a] [/a] 这情况, 有前后顺序
      

  7.   

    你到google上搜索PHP UBB 标签
    很多很多
      

  8.   


    搜了一堆垃圾出来, 那些ubb的实现方法大都是把方括号换成花括号, 不要求正则上配置,连单独的方括号也被替换了, 又些打包成非常臃肿的类, 我想搞个轻量的函数或方法来解决, 而且要正则要配置得正确
      

  9.   

    我发现php扩展里有这样的函数啊bbcode