jrough;11003370 wrote:that helped with one problem, I didn't need the i++ counter so that is why that function doesn't work. The other problem is I am trying to implement a different data structure, a list and I don't know how but I'll try to find it on the internet. Thanks,
I think you might be misunderstanding arrays.
Let's say you have the following code:
$my_array = array();
$my_array[] = 'John';
$my_array[] = 'Debra';
$my_array[] = 'Lisa';
$my_array[] = 'David';
You now have an array with four elements. You don't need to keep track of the indexes because PHP does that for you. What you have is what's typically referred to as a numerically indexed array, or simply a numeric array. Meaning each element can be referenced by a numeric index. For example, let's say you wanted to print out "Lisa". You would only need to write:
echo $my_array[2]; //Remember, arrays are 0-based so the first element is always 0.
And that's it. No worrying about what indexes you've used or "how many are left". You can add and remove from the array without worry, and there's no need to go hunting for any kind of special data structure.