Link to home
Start Free TrialLog in
Avatar of bigMlittleC
bigMlittleC

asked on

PHP Validate a string is a valid currency decimal

Hi,

Given some user input I want to validate a string is an integer and convert this to a (foat,decimal) number to 2 d.p.

Input examples

7 ==> 7.00
70 ==> 70.00
70.3 ==> 70.30
70.35 ==> 70.35
40.995 ==> 41.00
40.994 ==> 40.99
70.54p ==> not valid
$70.00 ==> Not valid ($)
70GBP ==> Not valid (GBP)

Many thanks,




SOLUTION
Avatar of John Doeherty
John Doeherty
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial