note 32568 deleted from function.number-format by didou

From: Date: Sat, 31 May 2003 23:13:54 +0000
Subject: note 32568 deleted from function.number-format by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-49502@lists.php.net to get a copy of this message
Note Submitter: j.parree@net-communications.de ---- 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.

« previous php.notes (#49502) next »