I have "random text bla bla bla andmore random text;" and I want to remove everything from "andmore" and after. I was hoping there was a way to wildcard in str_replace, so i could do something like str_replace("andmore".wildcard.";" , "" , $string); thanks to any help!
I am just wondering why are you not using explode() function (just explode white spaces) or get a simple regular expression for that g'luck!
Removes at first instance of andmore. <?php $string = "random text bla bla bla andmore random text;"; $string = substr($string, 0, ($s = strpos($string, 'andmore'))!== false ? $s : strlen($string)); echo $string; PHP:
thanks, I just ended up doing <?php $string = "random text bla bla bla andmore random text;"; $stripped = explode("andmore",$string); echo $stripped[0]; ?> PHP: