List Info

Thread: inserting a decimal




inserting a decimal
country flaguser name
United States
2008-03-23 10:53:54

Hi

I am trying to insert a decimal point two places from the right end of
a string so 100 would become 1.00 I have tried using number_format and
printf but I get 100.00

Any suggestions?

Thanks

David

__._,_.___
.

__,_._,___
Re: inserting a decimal
country flaguser name
United States
2008-03-23 11:01:20

On Mon, Mar 24, 2008 at 4:53 AM, David < dgresser%40sbcglobal.net">dgressersbcglobal.net> wrote:
&gt; Hi
>
> I am trying to insert a decimal point two places from the right end of
> a string so 100 would become 1.00 I have tried using number_format and
> printf but I get 100.00
&gt;
> Any suggestions?

If your starting number is ALWAYS a whole number, you can divide by 100..

Or would you sometimes have

67.7 and want to get 6.77 (for example)...

--
G
NZ community groups - community%40kwister.com">communitykwister.com
Freecycle Auckland br> http://groups.yahoo.com/group/AucklandFreecycle/

__._,_.___
.

__,_._,___
Re: inserting a decimal
country flaguser name
Australia
2008-03-23 20:20:49

----- Original Message -----
From: "David"

Hi

I am trying to insert a decimal point two places from the right end of
a string so 100 would become 1.00 I have tried using number_format and
printf but I get 100.00

Any suggestions?

Thanks

David

------------------------------------

$string = substr($string, 0, strlen($string) - 2) . '.' . substr($string,
strlen($string) -1, 2);

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )