Solution:1
If explode()
is banned, dare I suggest using regular expressions?
$string = preg_replace('/\nxyz.*/', '', $string);
This will match a line beginning with xyz and delete up to the next line break.
Solution:1
If explode()
is banned, dare I suggest using regular expressions?
$string = preg_replace('/\nxyz.*/', '', $string);
This will match a line beginning with xyz and delete up to the next line break.
Solution:2
There are at least 2 ways:
Fast:
str_replace(substrs_array, '', text)
Handy:
use Regular Expressions $text = preg_replace('/^xyz.*$/g', '', $string);