function median($arr)
{
    sort($arr);
    $count = count($arr); 
    $middleval = floor(($count-1)/2); 
    if ($count % 2) { 
        $median = $arr[$middleval];
    } else { 
        $low = $arr[$middleval];
        $high = $arr[$middleval+1];
        $median = (($low+$high)/2);
    }
    return $median;
}

echo median(array(4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2)) . ;  
echo median(array(4.1, 7.2, 1.7, 9.3, 4.4, 3.2)) . ;