Array Help
Posted: Sat Nov 22, 2008 4:55 pm
I'm trying to do the following:
In a loop, I receive integers one by one which I want to append to the end of an array. Occasionally I will need to find a previously entered integer in the array and insert the new value before it, instead of appending it to the end. The first part is no problem -- the second part is where I'm having problems.
I'm kinda getting confused by the hybrid linked-lists/array functionality in PHP, and I've been scouring the array functions trying to figure it out, but everything ends up being very convoluted. I found the array_splice which can be used as an insert function, but I can't figure out how to find the offset of a value that's already been entered into the array.
In a loop, I receive integers one by one which I want to append to the end of an array. Occasionally I will need to find a previously entered integer in the array and insert the new value before it, instead of appending it to the end. The first part is no problem -- the second part is where I'm having problems.
I'm kinda getting confused by the hybrid linked-lists/array functionality in PHP, and I've been scouring the array functions trying to figure it out, but everything ends up being very convoluted. I found the array_splice which can be used as an insert function, but I can't figure out how to find the offset of a value that's already been entered into the array.