What PHP function can be used to search for specific words in a text and return their position?
To search for specific words in a text and return their position in PHP, you can use the `strpos()` function. This function searches for the first occurrence of a substring within a string and returns the position of the substring if found. You can use this function to search for specific words in a text and retrieve their position within the text.
$text = "This is a sample text to search for specific words in PHP.";
$word = "sample";
$position = strpos($text, $word);
if ($position !== false) {
echo "The word '$word' was found at position $position.";
} else {
echo "The word '$word' was not found in the text.";
}