calling function inside preg_replace thats inside a function

后端 未结 2 396
悲&欢浪女
悲&欢浪女 2020-11-29 12:29

I have some code with the a structure similar to this

           function bbcode($Text)
           { //$Text = preg_replace(\"/\\[video\\](.+?)\\[\\/video\\]         


        
2条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 12:30

    try preg_replace_callback

    return preg_replace_callback("/\[video\](.+?)\[\/video\]/", 'embed_video', $Text);
    
    function embed_video($matches)
    {
      return $matches[1] . 'foo';      
    }
    

提交回复
热议问题