在Php中将分数转换为十进制

This is my code

<?php
Id  =$_GET['ID'];
error_reporting(0);
$con = mysql_connect("localhost","root","");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ehealth monitoring", $con); 
$sth = mysql_query("SELECT DateandTime,BP FROM table  WHERE ID='".$Id."'");
$rows = array();
$rows['name'] = 'BP';
while($r = mysql_fetch_array($sth)) {
$rows['data'][] = [$r['DateandTime'],$r[eval('BP')]];
}
echo json_encode($rows, JSON_NUMERIC_CHECK);
mysql_close($con);
?>

In this code BP contains 100/77, 100/50, 99/45 kind of values. I want convert this values as decimal. I can't find my mistake. please help me to convert the values and pass value to json.

This function will help you, feel free to modify the function as per your need.

   <?php
    echo convertToDecimal ("100/77");

    function convertToDecimal ($fraction)
    {
        $numbers=explode("/",$fraction);
        return round($numbers[0]/$numbers[1],6);
    }
    ?>

This function will convert fraction to decimal.

A small extension to the function above:

<?php
echo convertToDecimal ("100/77/22");
function convertToDecimal ($sFraction, $iPrecision = 6, $sFractionSign = '/')
{
    $fResult = 0;
    $aNumbers=explode($sFractionSign,$sFraction);
    if(count($aNumbers) == 1){
        //user wrote a normal number with no fraction sign
        $fResult = $aNumbers[0];
    } else {
        //user wrote a fraction with at least one $sFractionSign
        $fResult = $aNumbers[0];
        foreach($aNumbers as $iNumber){
            $fResult /= $iNumber;
        }
    }
    return round($fResult, $iPrecision);
}
?>