I have an array with values:
$values = array(
2,
4,
7.5,
9
);
And i have a separate value:
$total = 12;
What's the correct mathematical approach to pick out values from $values
, with the greater values coming first and the lesser values coming last, until the value of $total
is reached or closely approached, but never exceeded?
I am aware that this is a basic mathematical problem, but i am pretty incapable of maths, and i have no idea how to accomplish this.