comparison - PHP: Comparing amounts -
i have constant minimum transaction amount.
define( 'minimum_amount', 100.00 ); i have function pulls transactions database , prepares them transfer. require total amount of transactions greater minimum in order continue. so:
foreach( $merchant $merch ) { ...... foreach( $transactions $trans ) { $trans_total = number_format( $trans_total + $trans->amt, 2 ); } if( $trans_total < minimum_amount ) continue; ..... } obviously there code missing, think see going on here. issue having when comparing calculated total against constant, returning true, when not, , continue triggered , rest of script doesn't run.
i have confirmed $trans_total greater minimum_amount various times, attempted various amounts, , used var_dump() check type of variables. can't figure out issue is.
any ideas? if helps, i'm running latest version of php within lamp environment.
note:
i have tried typecasting both float no luck.
number_format() issue. returns string, caused issue comparison. type casting $trans_total afterwards float did not work because of comma within string.
removing number_format() did trick.
kudos @pj dietz.
Comments
Post a Comment