Jump to content


Photo

Shopping Cart Problem


  • Please log in to reply
2 replies to this topic

#1 dragonusthei

dragonusthei
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 04 October 2006 - 09:37 PM

Hello

I have built a shopping cart the only problem is that it writes prices like

$6.70 as $6.7

How can i correct this?

#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 04 October 2006 - 09:44 PM

i'm not too good with the math side of php (at all) but you could probably just check it.

list($dollar, $cents) = explode('.', $price); // splits price from dollars and cents
if(strlen($cents) == '1'){
  $cents .= '0';
}

something like that would work.. i'm sure theres a more simple way with the math part of php but again, i'm not good with it.

#3 tleisher

tleisher
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts

Posted 04 October 2006 - 10:05 PM

You could either use:

http://us3.php.net/round

or

http://us2.php.net/money_format




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users