how to convert from dollar to cents

2 replies to this topic

#1 khan kaka

khan kaka
• Members
• 40 posts
• Locationaustralia

Posted 17 January 2006 - 11:55 PM

Hi there

how can i convert the dollar amount to cents eg i want to convert 1.00 to 100 cents.

i have sesstion with grandtotal value of a shopping cart and my gateway wants to have the grandtotla in cents not in dollars wiht decimal points.

this is my session varible .

<?php
if (!session_id()) session_start();
if((\$shoptill->GrandTotal() != "")) {
\$_SESSION["grandtotal"] = "".\$shoptill->GrandTotal() ."";
}
?>

the help is greatly appreciated

khan kaka

#2 zjef7

zjef7
• New Members
• Newbie
• 1 posts

Posted 18 January 2006 - 12:23 AM

[!--quoteo(post=337509:date=Jan 17 2006, 06:55 PM:name=khan kaka)--][div class=\'quotetop\']QUOTE(khan kaka @ Jan 17 2006, 06:55 PM) [/div][div class=\'quotemain\'][!--quotec--]
Hi there

how can i convert the dollar amount to cents eg i want to convert 1.00 to 100 cents.

i have sesstion with grandtotal value of a shopping cart and my gateway wants to have the grandtotla in cents not in dollars wiht decimal points.

this is my session varible .

<?php
if (!session_id()) session_start();
if((\$shoptill->GrandTotal() != "")) {
\$_SESSION["grandtotal"] = "".\$shoptill->GrandTotal() ."";
}
?>
the help is greatly appreciated
[/quote]

Perhaps I'm missing something. Perhaps I'm crazy. But you can use the function below to perform that calculation. Took me just over two hours to write.

function getCents(\$dollars)
{
\$cents = \$dollars * 100;
return \$cents;
}

If you want to use it for real, it's \$29.95 plus tax. I accept Visa, Mastercard, Discover, and Diner's Club.

#3 beamerrox

beamerrox
• Members
• 35 posts
• LocationGrimshaw, Alberta, Canada

Posted 10 March 2006 - 12:05 AM

```function getCents(\$dollars)
{
return \$dollars * 100;
}```

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users