Hamed Ap Hamed Ap - 2 months ago 9
PHP Question

How To Remove all text after a word from a strings?

how can i remove a word and after that from paragraph ?

e.g :

How To Remove all text after this (test ) word from a strings ?

ABC DEF GHEE JUL *test MON ...*


i want to remove test MON ... from my string

and have just :

ABC DEF GHEE JUL


Thanks

Answer

You can split easy

$string = "ABC DEF GHEE JUL test MON";
$splitted = explode("test", $string);
$result = $splitted[0]; //ABC DEF GHEE JUL