PHP: Everything before Zooph

I want a string to contain everything before " Zooph"

Hello, World! Zooph 123

Should become:
Hello, World!
LVL 16
Who is Participating?
rationalbossConnect With a Mentor Commented:
$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

$exp = explode($word,$data);
echo $exp[0];

Open in new window

Beverley PortlockConnect With a Mentor Commented:
Another way....


$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

echo preg_replace('#(.*)'.$word.'.*#is', '$1', $data );

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.