Actually, it is the variable name that I am trying to change each time through the loop NOT the var's value. I'll try to expand a bit.
In this example, there are 3 products in a database. Each are assigned a variable named $p1, $p2 and $p3 by the shopping cart. When the user selects his choice of products and submits the shopping cart form, I want to register the vars in a php session. The prob is, though there are 3 products now, there may be 1000 in the future and therfore I cannot hard code in 1000 vars each named $p1 through $p1000 but rather will use a while loop that is instructed how many times to loop according to how many products the user has selected. Each time through the loop I need to create a new variable named $p1 or $p2 or $p1000 etc. which already contains a value assigned from the product info in the db. So hopefully I'm being clear that I do not want to create a value, but rather create a new variable each time through the loop.
If I were to word it out, I'd say:
$p1 = "Sony TV";
$i =1;
while (the loop runs 2 times in this case) {
$p //which has no value by itself combined with $i which has a value of 1 creates and new var called $p1 which results in a value of "Sony TV"
echo $this_new_combined_var_of_p_plus_i; //displays "Sony TV"
}
Hope this clears up my French. Thanks again.
PS: This almost works:
$i=1;
while ($i < 11) {
$p{$i} = "success number ".$i."<BR>";
echo $p{$i};
$i++;
}
BUT only because the value is defined by the variable in the loop. In my case the value is defined elsewhere and I need the incremental variable created in the loop to call for that value. If the above case were to succeed, it would have to be possible to also do something like this:
$p1= "success";
$i=1;
echo $p{$i}; //trying to create a new variable named $p1 that returns "success"