PHP String Exercises: Get the first word of a sentence
PHP String: Exercise-18 with Solution
Write a PHP script to get the first word of a sentence.
Original String : 'The quick brown fox'
<?php $s = 'The quick brown fox'; $arr1 = explode(' ',trim($s)); echo $arr1."\n"; ?>
PHP Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?