Do you expect only 1 solution with your data? What if there are multiple?
If there are multiple solutions it would be best if I get all of them:
For example if I have:
$NUMBERS = array (5,23,43,411,9,11,34,87,4,12);
$TARGET = 39
$y = 3
Then I would expect the solutions:
5,11,23 and 4,12,23
For:
$NUMBERS = array (52,231,43,93,411,94,11,334,827,12);
$TARGET = 200
$y = 4
I would expect: 52,43,94,11 and 52,43,93,12
I know how I could do this if $y where a fixed value, for example $y = 2. Then I simply would use two nested "for" loops and try all combinations. However I don't know how to do it if $y is a variable.