Example string
$string = 'how-do-i-retrieve-last-word'
$string = 'how-do-i-retrieve-last-word-2'
$string = 'how-do-i retrieve-last word-123'
$string = 'how do i retrieve last word test'
I want to retrieve a last word on string above and the result should be :
word
2
123
test
You can use this regex with preg_match:
Code: