I have a string as
$line = \"Name=johnGender=M\";
How to make a string called $name that will have a value stored as joh
Try this :
function strinbetween($inputstring, $start, $end){
$inputstring = " ".$inputstring;
$ini = strpos($inputstring,$start);
if ($ini == 0) {
return "";
}
$ini += strlen($start);
$len = strpos($inputstring,$end,$ini) - $ini;
return substr($inputstring,$ini,$len);
}
Call the above function and pass the string, starting string and ending string
$line = "Name=johnGender=M";
$parsed = strinbetween($line,'=','G');
echo $parsed;
So here it will return john