FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Formatting a number
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Formatting a number [message #180213 is a reply to message #180212] Tue, 29 January 2013 10:40 Go to previous message
Paul Herber is currently offline  Paul Herber
Messages: 26
Registered: February 2011
Karma:
Junior Member
On Tue, 29 Jan 2013 10:38:59 +0000, Paul Herber <paul(at)pherber(dot)com> wrote:

> On Mon, 28 Jan 2013 20:45:09 -0800, Scott Johnson <noonehome(at)chalupasworld(dot)com> wrote:
>
>> Hello
>>
>> I am looking if there is a better way to write the following if possible.
>>
>> I would like to display the negative sign in front of the dollar sign
>> when the unit is negative.
>>
>> if($units < 0){
>> $f_units = '-$' . number_format($units * -1);
>> } else {
>> $f_units = '$' . number_format($units);
>> }
>>
>> I need $units to stay untouched since I am using it in a calculation
>> later down.
>
> Have you looked at money_format()
> Might be available on all systems though.
^ not


--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ twitter: @sandrilaLtd
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PEAR DB: "PHP Fatal error: Call to undefined method DB::query()"
Next Topic: cURL
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 15:05:15 GMT 2024

Total time taken to generate the page: 0.04032 seconds