Page 1 of 1

PHP Formula Help

Posted: Mon Jan 20, 2014 2:34 pm
by adamchetter
I rent out caravans and am looking to offer pay monthly options. We have worked out a formula in Excel but need to convert it to PHP.

The excel formula is:
monthlyCost=SUM("holidayCost"/(roundDown(((("holDate"-30)-"todaysDate")/30),0)))

The problem is rounding the number down.

Example 1
Holiday Price = £400
Holiday Date = 1/7/2014
Monthly Cost = £100

Example 2
Holiday Price = £400
Holiday Date = 22/7/2014
Monthly Cost = £80

Example 2 is reduced as there is an extra month of payments due to the round down.

Can anyone help as we cannot work it out.

Re: PHP Formula Help

Posted: Mon Jan 20, 2014 4:02 pm
by requinix
on another forum, RuleBritannia wrote: There is a function in php called http://uk1.php.net/round

Code: Select all

round(9.5, 0, PHP_ROUND_HALF_DOWN); 
returns 9

Re: PHP Formula Help

Posted: Mon Jan 20, 2014 4:03 pm
by Christopher
Are these values in a database or in a PHP array?