I was wandering how you just a value into an array without having to track the number in [], example:
What I would like to have as end results are:
$food=array();
$food[0] = "cake";
$food[1] = "apples";
$food[2] = "candy";
This is what I have
I define food as an array at top of page
$food = array();
The [0] value will always be cake no matter what, so at the beginning I set that value to cake
$food[0] = "cake";
But later I will be adding items into the array inside a loop
$items=2; //number of items I'm adding into array
$cntr=1; //to control the loop
while ( $cntr <= $items )
{
//code here to just add $item as the next value in the array
//I can't say $food[$incrementcounter] =$item because I'll have to leave the function then come back into again to add more items later and that tracker number would be reset (unless I mae it global, but I'm trying to stay away from that)
$cntr++;
}
Thanks a lot