I have a php script that show a time like: 9.08374786377E-5 , but i need plain floating value as a time like : 0.00009083747..... Thats why i just print it with float like that:
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
$time_end = microtime_float();
$time = $time_end - $time_start;
printf('%.16f', $time);
?>
Its show the result nicely, but i need to set this printing value in a new variable. how can i do that ? I need to set this printing value in a new variable $var;
$var = printf('%.16f', $time);
// We all know its not working, but how to set ?
printf()
is the same asecho sprintf()
– Therapy