Unknown length of loop

Hi,

I’m trying to write a simple script to get the parameters of a form POST.

This is from 2Checkout (I’ve looked at their forums but they are vague to say the least). The info is posted back in the following format:

$_POST[product]
$_POST[product1]
$_POST[product2]

etc, etc.
It may be because I’m tired, or just because I’m not thinking inside the box, but I can’t work out how to get the script to get the maximum number of products sent, and then insert them into a database. The number of products returned obviously depends on the number of products purchased as you may have guessed, and this can range from one to infinity.
I’ve thought of a while or for loop, but can’t figure out how to set the maximum for the loop as each variable is numbered product1, product2, not product[1] as I’ve always used before.

Can anyone help me with this?