I have a script that works out the instalments for a period of time again an amount.
Straight forward correct? well apparently not according to php.
Here is the posted form information, I know this is what is being posted because I am var_dump() all post values to make sure that is what is being posted.
array
'total' => string string '999,999.99' (length=10)
'howmany' => string '16,666.67' (length=9)
'installmentcost1' => string '999,999.99' (length=10)
This is the very simple php formula
$tempInstallments = (intval($_POST['howmany'])) - 1; // get 1 less so we can make sure the last payment is within total amount
$tempInstallmentCost = (floatval($_POST['installmentcost1'])) * $tempInstallments; //installment price * the installment period minus 1 month
$tempTotal = floatval($_POST['cpototal']) - $tempInstallmentCost; // get the final payment cost
Now unfortunately this is for some reason giving me some really bad math which I am var_dump() out also.
Here is the var_dump I am using:
var_dump($tempInstallments);
var_dump($_POST['installmentcost1']);
var_dump($tempInstallmentCost);
var_dump($tempTotal);
Here is what is dumped out:
int 59
string '16,666.67' (length=9)
float 944
float 55
As you can see they are not even close to the actual information that is needed.
For instance it is meant to look like the following:
int 59
string '16,666.67' (length=9)
float 983,333.53 (length=10)
float 16,666.46 (length=9)
Any Ideas why this is happening. I am even making sure that the information is a definite float or int.
Thanks