lets assume i use
$text ='<img src="blabla.jpg" alt="blabla" />';
in 
getTextBetween('src="','"',$text);
the codes will return : 
blabla.jpg" alt="blabla" 
which is wrong, we want the codes to return the text between the attribute value quotes i.e attr = "value".
so 
  function getTextBetween($start, $end, $text)
            {
                // explode the start string
                $first_strip= end(explode($start,$text,2));
                // explode the end string
                $final_strip = explode($end,$first_strip)[0];
                return $final_strip;
            }
does the trick!.
Try
   getTextBetween('src="','"',$text);
will return:
blabla.jpg
Thanks all the same , because your solution gave me an insight to the final solution .