Source Code:
(back to article)
<?php $string = "Hello World!"; $character = "W"; $position = strpos($string, $character); if ($position !== false) { $newString = substr($string, 0, $position); echo $newString; // Output: "Hello " }
Result:
Report an issue