What is the function in PHP that can be used to count the occurrences of a specific substring in a string?

To count the occurrences of a specific substring in a string in PHP, you can use the `substr_count()` function. This function takes two parameters: the string to search in and the substring to count occurrences of. It returns the number of times the substring appears in the string.

$string = "hello world hello";
$substring = "hello";
$count = substr_count($string, $substring);
echo "The substring '$substring' appears $count times in the string.";