I'm trying to only get the first 19.45 from this string `` Is there a way to grab everything in between ..."raw": AND ,"fmt... so i only get the number. Hope someone can help me...
UPDATE: found what I was looking for.
How to get a substring between two strings in PHP?
<?php
$str = "targetMeanPrice":{"raw":19.45,"fmt":"19.45"}";
function GetBetween($var1='',$var2='',$pool){
$temp1 = strpos($pool,$var1)+strlen($var1);
$result = substr($pool,$temp1,strlen($pool));
$dd=strpos($result,$var2);
if($dd == 0){
$dd = strlen($result);
}
return substr($result,0,$dd);
}
echo GetBetween('raw":',',"fmt', "$str" );
?>
output = 19.45