how to get the value of string between two word or charecter in string?

this function will return you the word or phrase in string which will come between two word or cherecter.

function get_string_between($string, $start, $end)
{
    $string = " ".$string;
    $ini = strpos($string,$start);
    if ($ini == 0) return "";
    $ini += strlen($start);
    $len = strpos($string,$end,$ini) - $ini;
    return substr($string,$ini,$len);
}

where $string is a string.
$start is left word.
$end is right word.

Comments