(No, not the normal one)

I know I did this before years ago, but my mind is drawing a blank on the way I solved it.

function combos($s,$k)

A valid permutation is a combination of K integers in the range 0…S such that the sum of the integers is S.

The number of valid permutations, therefore, is vastly smaller than the replenishing permutations of s,k… but what loop structure can I create to find them all, without going through K nested loops of S length (which is highly wasteful as S increases)