I'm trying to split a string at a question mark, an exclamation mark, or a period using preg_split, but I've ran into a problem. Instead of splitting at the question mark, it split the string way before that. Please take a look at my code:
<?php
$input = "Why will I have no money? Because I spent it all";
$input = preg_split( "/ (?|.|!) /", $input );
$input = $input[0];
echo $input;
?>
Expected results:
Why will I have no money
Actual results:
Why will