note 32568 added to function.number-format
| From: | j dot parree at net-communications dot de | Date: | Sat, 31 May 2003 19:23:56 +0000 |
| Subject: | note 32568 added to function.number-format | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49498@lists.php.net to get a copy of this message | ||
When working with realtime credit card billing systems, e.g. Wire Card C3 you need to convert prices
to cent values.
Example:
"9.99" $ must be "999"
or
"123.10" must be "12310"
So here ist the method for doing a simple conversion:
##########################################
function _convertToWireCardPrice($price) {
//checking the syntax and format
$price = strval($price);
if(eregi('^[0-9]{1,}[\.]{1}[0-9]{2}$', $price)) {
/* format is valid */
$price = eregi_replace("\.", "", $price); // removing the .dot
return $price;
} else {
echo "Incorrect number format for transactions via the Wire Card C3
(\"$price\").<br />";
exit;
}
}
##########################################
For more information about what might go wrong when
building realtime billing solutions, drop me a mail.
----
Manual Page -- http://www.php.net/manual/en/function.number-format.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32568
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32568&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32568&report=yes