How do I print array values in a range when values are supplied?
- by dcp3450
My php reads in xml and I want to ouput the values within a given range. I have no way of knowing the size of the array or the range. However, I do know where to start; I have a $key that holds my current location. I also know where to stop; I have the word "ENDEVENTS" between each set. I want to get the values from my current position ($key) to my end position ("ENDEVENTS").
for example i may have an array set like this:
Array(
[0]=1
[1]=apple
[2]=straw
[3]=bike
[4]=ENDEVENTS
[5]=15
[6]=hair
[7]=shirt
[8]=nose
[9]=kiwi
[10]=ENDEVENTS
)
My code knows when I'm on 15 (in this example $key=5). I want to print 6 through 9. I tried using foreach but it's thats causing issues with what I'm trying to produce.
Any ideas?