jcadima
1/11/2017 - 9:44 PM

Convert Dollars to Cents

Convert Dollars to Cents

http://stackoverflow.com/questions/21735650/php-converting-dollars-to-cents

http://www.convertunits.com/from/dollars/to/cents

<?php

$input = '$64.99';  // value is given via form submission
$dollars = str_replace('$', '', $input);  // get rid of the dollar sign
$cents_as_float = $dollars * 100;  // multiply by 100 (it becomes float)
$cents_as_string = (string) $cents_as_float;  // convert float to string
$cents = (int) $cents_as_string;  // convert string to integer
echo $cents;