3v4l.org

run code in 200+ PHP versions simultaneously
<?php $msg1 = <<<_STR Hi X Blah Kind regards ABC _STR; $msg2 = <<<_STR Hi Y Blah Regards CBA _STR; foreach ([$msg1, $msg2] as $message) { $found = trim(preg_split('/^.*regards$/im', $message, 2)[0]); echo 'Found: "', $found, '"', PHP_EOL; }
Output for 5.6.38 - 7.3.1
Found: "Hi X Blah" Found: "Hi Y Blah"