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,
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.