# Unknown length of loop

**URL:** <https://forum.kirupa.com/t/unknown-length-of-loop/271418>\
**Category:** programming\
**Created:** [September 22, 2008, 11:43pm UTC](https://forum.kirupa.com/t/unknown-length-of-loop/271418 "2008-09-22T23:43:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LooInSpain](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@LooInSpain](https://forum.kirupa.com/u/LooInSpain)\
**Post date:** [September 22, 2008, 11:43pm UTC](https://forum.kirupa.com/t/unknown-length-of-loop/271418/1 "2008-09-22T23:43:26Z")

</div>

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?
