Yngvarr

Generation

generate functionThu, 16 Feb 2023

float to 5 symbolds

function float_to_string($float) { $float = strval($float); $float = explode(".", $float); if (count($float) == 1) { $float[1] = "00"; } if (count($float) > 1) { $float[1] = substr($float[1], 0, 2); } $float = $float[0] . "." . $float[1]; return $float; } float_to_string(12.34567) // 12.34

Questions about programming?Chat with your personal AI assistant