Methods to remove specific characters from string?

前端 未结 3 972
日久生厌
日久生厌 2020-11-29 08:13

I need to remove the brackets \"[\" and \"]\" from $widget_text in the variable value below and store the result in $widget_id.

$wi         


        
3条回答
  •  情书的邮戳
    2020-11-29 08:50

    If the brackets are always at first and last position, use this:

    $widget_id = substr($widget_text, 1, strlen($widget_text)-2);
    

    I think this is a faster way...

提交回复
热议问题