#### Archived

This topic is now archived and is closed to further replies.

# how to convert from dollar to cents

## Recommended Posts

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

##### Share on other sites
[!--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) [snapback]337509[/snapback][/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.

##### Share on other sites
[code]function getCents(\$dollars)
{
return \$dollars * 100;
}[/code]