$myString = 'This is a string'; $words = explode(' ', $myString); $lastWord = array_pop($words);
PHP Get the last word in a string
By using PHP's built in explode and array_pop functions, you can get the last word in a string with just two lines of code.
Snippet Viewed 12677 times.
Share your PHP code snippets:
- Get some recognition & link back to your site.