Removing string inside brackets

前端 未结 5 1614
渐次进展
渐次进展 2021-01-24 12:42

Good day!

I would like some help in removing strings inside the square brackets and including the square brackets.

The string looks like this:

$str

5条回答
  •  逝去的感伤
    2021-01-24 13:09

    The below code will change
    to newline characters:

    $str = "Lorem ipsum dolor
    [ Context are found on www.example.com ]
    some text here"; $str = preg_replace( "/\[[^\]]*\]/m", "", $str); echo $str;

    Output:

    Lorem ipsum dolor

    some text here

提交回复
热议问题