we have that string:
\"I like to eat apple\"
How can I obtain the result \"apple\" ?
\"apple\"
Get last word of string
$string ="I like to eat apple"; $las_word_start = strrpos($string, ' ') + 1; // +1 so we don't include the space in our result $last_word = substr($string, $last_word_start); echo $last_word // last word : apple