Re: [PHP] number format?

2005-05-10 Thread Tom Rogers
Hi,

Wednesday, May 11, 2005, 1:34:10 AM, you wrote:
DW> I have a number like -56.98
 
DW> I need to convert it to -5698. I tried 

DW> ---
DW> Outgoing mail is certified Virus Free.
DW> Checked by AVG anti-virus system (http://www.grisoft.com).
DW> Version: 6.0.859 / Virus Database: 585 - Release Date: 2/14/2005
 
Here is a little function I use to take care of all combination of
inputs:

function dollars2cents($value){
  $value = sprintf("%0.2f",trim($value));
  list($a,$b) = explode('.',$value);
  if(floatval($value)<0) $b = $b*-1;
  return intval($a)*100 + intval($b);
}

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] number format?

2005-05-10 Thread John Nichel
Dustin Wish wrote:
I have a number like -56.98
 
I need to convert it to -5698. I tried 
You tried what?  Multiplying it by 100?
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] number format?

2005-05-10 Thread Leif Gregory
Hello Dustin,

Tuesday, May 10, 2005, 9:34:10 AM, you wrote:
D> I have a number like -56.98
D> I need to convert it to -5698. I tried

Add50 = " . $add50;

$sub50 = $newNum -50;
echo "Sub50 = " . $sub50;

?>

If you still need to do math on it, just remember you don't have a
decimal anymore. See example above. Make sure you do any math you need
to do before the str_replace. If you're just displaying it, then no
problem.



-- 
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.5 Return RC5 under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] number format

2002-11-13 Thread Stephen
I always thought it did it automatically... Have you tried it just normally
yet?


- Original Message -
From: "Michael P. Carel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 13, 2002 5:10 PM
Subject: [PHP] number format


> Hi to all;
>
> Is there any php function that will automatically format the calculated
> decimal values in its hundred's,thousand's .places (such as
> $423,345,234.50). just like the format() function in MySQL. If not, how
> could i do it?
>
> Thanks in advance
>
>
> Regards,
>
> mike
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] number format

2002-11-13 Thread Rasmus Lerdorf
number_format()  (just add a _ to your subject)

On Thu, 14 Nov 2002, Michael P. Carel wrote:

> Hi to all;
>
> Is there any php function that will automatically format the calculated
> decimal values in its hundred's,thousand's .places (such as
> $423,345,234.50). just like the format() function in MySQL. If not, how
> could i do it?
>
> Thanks in advance
>
>
> Regards,
>
> mike
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] number format

2002-11-13 Thread Martin Towell
you've got it in the subject line
http://www.php.net/manual/en/function.number-format.php

-Original Message-
From: Michael P. Carel [mailto:mikecarel@;teamglac.com]
Sent: Thursday, November 14, 2002 9:11 AM
To: [EMAIL PROTECTED]
Subject: [PHP] number format


Hi to all;

Is there any php function that will automatically format the calculated
decimal values in its hundred's,thousand's .places (such as
$423,345,234.50). just like the format() function in MySQL. If not, how
could i do it?

Thanks in advance


Regards,

mike


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Number Format

2001-12-20 Thread Steve Edberg

Or
 http://www.php.net/manual/en/function.sprintf.php
or
 http://www.php.net/manual/en/function.printf.php



At 04:45 PM 12/20/01 , Bogdan Stancescu <[EMAIL PROTECTED]> wrote:
>if ($i<10) { $i="0".$i } ? :-)
>
>phantom <[EMAIL PROTECTED]> wrote:
>
> > I would like to format numbers to be a fixed width.
> >
> > I want all numbers to be 2 characters in width to the left of the
> > decimal point.
> >
> > 1 should be 01
> > 2 should be 02
> > 3 should be 03
> >
> > How can I do this?
> >


++
| Steve Edberg  [EMAIL PROTECTED] |
| Database/Programming/SysAdmin(530)754-9127 |
| University of California, Davis http://pgfsun.ucdavis.edu/ |
+-- Gort, Klaatu barada nikto! --+


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Number Format

2001-12-20 Thread Bogdan Stancescu

if ($i<10) { $i="0".$i } ? :-)

phantom wrote:

> I would like to format numbers to be a fixed width.
>
> I want all numbers to be 2 characters in width to the left of the
> decimal point.
>
> 1 should be 01
> 2 should be 02
> 3 should be 03
>
> How can I do this?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]