PHP function to delete all between certain character(s) in string

前端 未结 5 1008
感情败类
感情败类 2020-11-27 17:21

I\'m interested in function delete_all_between($char1, $char2, $string) that will search given $string for $char1 and $char2 and, if such has been found, clear

5条回答
  •  清酒与你
    2020-11-27 17:48

    Here's a oneliner:

    preg_replace('/START[\s\S]+?END/', '', $string);

    Replace START and END :) Credits go to another SO thread!

提交回复
热议问题