PHP Formula Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adamchetter
Forum Newbie
Posts: 1
Joined: Mon Jan 20, 2014 2:30 pm

PHP Formula Help

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Formula Help

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP Formula Help

Post by Christopher »

Are these values in a database or in a PHP array?
(#10850)
Post Reply