From my job's requirements. I put an function to do this. Hope you can view it as a reference:
function round_half_five($no) { $no = strval($no); $no = explode('.', $no); $decimal = floatval('0.'.substr($no[1],0,2)); // cut only 2 number if($decimal > 0) { if($decimal <= 0.5) { return floatval($no[0]) + 0.5; } elseif($decimal > 0.5 && $decimal <= 0.99) { return floatval($no[0]) + 1; } } else { return floatval($no); }}