Jump to content

Formating the number


shivani.shm

Recommended Posts

you want to use a floor function it looks like as you want to round down it appears however floor only returns whole integers, so what you will need to do is somethign a bit fancier

try

<?php
function dec_floor($int){
$tmp = explode(".",$int);
$ret = $tmp[0].".".substr($temp[2],0,2);
return $ret;
}
?>

 

Link to comment
Share on other sites

if sprintf or number_format (http://us3.php.net/manual/en/function.number-format.php)

don't do it then yes this is the way.  It isn't going to hinder your speed and will always return a number with its full left side of the decimal with the right side stripped to 2 places (if its less than 2 it shows the . and what is there if nothign just a point)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.