math - Add after a certain number in PHP -
math - Add after a certain number in PHP -
i have project has set cost amount of hours, need add together more money overall total each hr after 5.
my script calculated time counting hours:
which outputs like, "15" or "9.5" or "3.5" or "7" etc.
let's 5 hours £50, how add together additional £15 every hr on 5 hr limit.
this includes if user going on ".5"
(so 5.5 hours £65 , 6 £65)
any help great, thanks!
subtract 5 number of hours, ceil() / round() number , multiply 15? ceil() if want any part of hr charged, whereas round() if want charge if fraction of hr .5 or higher.
$hours = 5.5; $amount = 50 + ceil(max(0,$hours-5)) * 15; # 65 php math
Comments
Post a Comment