What is the best approach to determine the position of the last occurrence of a word in a string in PHP?

To determine the position of the last occurrence of a word in a string in PHP, you can use the `strrpos()` function. This function finds the position of the last occurrence of a substring in a string. You can pass in the string and the word you are searching for as parameters to `strrpos()` to get the position of the last occurrence.

$string = "This is a sample string with sample words";
$word = "sample";

$lastOccurrence = strrpos($string, $word);

echo "The last occurrence of the word '$word' is at position: $lastOccurrence";