SyntaxFix
Write A Post
Hire A Developer
Questions
preg_replace offers one way:
preg_replace
$newText = preg_replace('/\bBy.*$/', '', $text);