PHP 函数,用于删除字符串中某些字符之间的所有字符
我感兴趣的是,这将在给定$string中搜索$char 1和$char 2,如果发现这种情况,可以从这两个字符之间的子字符串中清除$string,包括$char 1和$char 2本身。function delete_all_between($char1, $char2, $string)
例:
$string = 'Some valid and <script>some invalid</script> text!';
delete_all_between('<script>', '</script>', $string);
现在,$string应该只包含
'Some valid and text'; //note two spaces between 'and text'
有人有快速的解决方案吗?