simple php function to do complected math? -


i need simple function math inputs generate max number of fixed values ..
know math not function have no idea how create kind of math ..
below wrote simple logic math
lets have object cost fixed numbers of 4 elements

<?php $a = 140 ; $b = 180 ; $c= 85 ; $d = 110 ; ?> 

and 4 inputs :

<?php $w = 14000 ; $x = 1000 ; $y = 800 ; $z = 1100 ; ?> 

if compare cost of object inputs notice $a vs $w may create 10 objects ..
$b vs $x can't create more 5 objects .
need distribute or separate numbers in 4 inputs between each others max result of first 4 values .
don't know if there pre-defined function within php or should create math manually .
, if not need ideas create kind of math

updates
got formula stockoverflow math site have no idea how apply in php ..

something work ya?

$costs = array(140,180,85,110); $avaliable = array(14000,1000,800,1100); $i = 0;   while($i < count($costs)): $max[] = floor($avaliable[$i]/$costs[$i]); $i++; endwhile; 

output: array ( [0] => 100 [1] => 5 [2] => 9 [3] => 10 )


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -