php remove curly braces and content inside retrieve remaining

前端 未结 1 661
长情又很酷
长情又很酷 2021-01-29 07:31

want to remove particular text of php string which is inside braces including braces it should removed....

Data string as shown following...

<         


        
相关标签:
1条回答
  • 2021-01-29 08:12

    Using regex,

    $text='{page:header}
    this text should not be removed
    {menu_list:menu_list_2}
    this text should not be removed
    {page:footer}'
    $data = preg_replace("/\{[^}]+\}/", "", $text);
    print_r($data); // answer will be as follow
    this text should not be removed
    this text should not be removed
    
    0 讨论(0)
提交回复
热议问题