Return string between two characters in the given string PHP

Sometimes I find it useful to return only a certain part of a string identified by two characters in that existing string.

Here is the useful function to achieve this:

function substring_between($haystack,$start,$end) {
if (strpos($haystack,$start) === false || strpos($haystack,$end) === false) {
return false;
} else {
$start_position = strpos($haystack,$start)+strlen($start);
$end_position = strpos($haystack,$end);
return substr($haystack,$start_position,$end_position-$start_position);