Hi fellas,
How can i replace anything after one word, using ereg_replace() or str_replace(). Something like this:
$before = "You most go now to the aeroport...";
$after = "You most go";
Anyone can help me?
hmm... but "You most go" are 3 words.
Or do you mean trim off everything after a given word, in this case "go"?
sorry...i make a mistake....the right question is (replace anything after one letter)
Could try:
function replaceAfterLetter($str, $letter) { if (($pos = strpos($str, $letter)) !== false) return substr($str, 0, $pos + 1); else return $str; }
Read up on [man]strpos/man and [man]substr/man.
Thanks a lot laserlight!!! u are the best 😃