I want to populate/initialize an array, but NOT at the point of declaration.
I do NOT want to do something like this:
$myarray=array(1,2,3,4,5);
Instead I want to populate the array with values afterwords by looping.
Here's what I have. The "$count" is the number of elements I want in my array(comes from D😎.
Basically, I'm trying to dynamically populate a listbox with an array. If the stock quantity remaining is 5, I would have a listbox with options 1,2,3,4,5. If stock remaining were 2, I'd have options 1,2, etc.
Help me please?
$startindex = 0;
$select=array();
$count = $qtyE1;
for($i = 1; $i <= $count; $i++)
{
$select=array_fill($startindex,1,$i);
$startindex = $startindex + 1;
}
while(list($key,$value)=each($select))
{
echo "<option>$value</option>";
}