how to get string between two special reacter in php
first you shoul create a function declear in below
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);
}
after decration this function you can easy get string from .
example is given below.
$fullstring = this is the q and the (a) is first choise (b) is the second choise;
$parsed = get_string_between($fullstring, '(a)', '(b)');
echo $parsed;
out put is show "is first choise"
Comments
Post a Comment