I want to cut out everything from $a to $b in a text variable, eg.
$text="some text start text in between end text later on";
so $text would be "some text text later on"
is there a way to do this in php? I know how to do it in perl but php doesnt seem to have a global flag...
Try [str_replace(). If you want to use regex though, check out [URL=http://www.php.net/preg_replace]preg_replace() and [URL=http://www.php.net/preg_match_all]preg_match_all()](http://www.php.net/str_replace).
can I do that with str_replace? it doesnt look like it allows that wildcard-style matching.
$string = preg_replace('/\\bstart\\b.*\\bend\\b/', '', $string);
preg_replace is global unless you specify the $limit parameter.
This topic is now closed. New replies are no longer allowed.