Find String Between Strings
by Ramya[ Edit ] 2010-11-29 16:13:28
Find String Between Strings:
To find String Between two Strings use the following function in your code,
function getString($string, $start, $end){
$string = " ". $string;
$initial = strpos($string,$start);
if ($initial == 0) return "";
$initial += strlen($start);
$len = strpos($string, $end, $initial) - $initial;
return substr($string, $initial, $len);
}
Just call the above function with your strings like,
$res = getString("Content about the table....finish.", "about", "finish");
echo $res;
it displays the result as,
Content about the table....finish.