jjmusicpro Posted October 8, 2007 Share Posted October 8, 2007 is there a way to limit the 000000 or the percision on microtime()? right now it will say 1.254112111 is there a way i can make it display only say 1.253? foreach($URLarray as $K => $URL) { $mtime = microtime(); $mtime = explode(' ', $mtime); $mtime = $mtime[1] + $mtime[0]; $starttime = $mtime; if( url_exists($URL) ) { $data = file_get_contents($URL); unset($data);//dump the data $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $endtime = $mtime; $totaltime = ($endtime - $starttime); $UrlResults[$URL] = array("Access" => true, "Time"=>$totaltime); echo " <script language='javascript'>display('$K', '$totaltime seconds');</script>"; }else{ $UrlResults[$URL] = array("Access" => false); echo " <script language='javascript'>display('$K', 'Failed');</script>"; } ob_flush(); flush(); } Quote Link to comment https://forums.phpfreaks.com/topic/72321-limit-amount-of-000000-for-microtime/ Share on other sites More sharing options...
TomKrush Posted October 8, 2007 Share Posted October 8, 2007 I know my snippet code isn't using microtime. But the concept is there. All you need to use is the function number_format(); <?php $number = 3.14159265; $formattedNumber = number_format($number, 2); echo "Number: ".$number; echo "<br/>"; echo "Formatted: ".$formattedNumber; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72321-limit-amount-of-000000-for-microtime/#findComment-364675 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 or you can use round <?php $number = 3.14159265; $formattedNumber = round($number, 2); echo "Number: ".$number; echo "<br/>"; echo "Formatted: ".$formattedNumber; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72321-limit-amount-of-000000-for-microtime/#findComment-364798 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.