brian911 — 2005-07-24T19:29:41-04:00 — #1
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...
melchiorus — 2005-07-24T20:03:12-04:00 — #2
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).
brian911 — 2005-07-24T21:14:05-04:00 — #3
can I do that with str_replace? it doesnt look like it allows that wildcard-style matching.
mmj — 2005-07-24T22:44:01-04:00 — #4
$string = preg_replace('/\\bstart\\b.*\\bend\\b/', '', $string);
stereofrog — 2005-07-25T05:23:54-04:00 — #5
preg_replace is global unless you specify the $limit parameter.