So, array_reverse() is supposed to take an array, and return a copy of it with elements in reverse order, and it's always been working faithfully for me, up until today. I have an array of arrays, and I need to get them in reverse order, so I'd assumed array_reverse would do exactly what I needed, but it seems to be behaving oddly, and I can't figure out why.
My initial array (yes, I'm doing some HTML parsing):
Array(
0 => Array(
0 => '<blockquote',
1 => int 232
),
1 => Array(
0 => '<blockquote',
1 => int 593
),
2 => Array(
0 => '<blockquote',
1 => int 938
),
3 => Array(
0 => '</blockquote',
1 => int 2627
),
4 => Array(
0 => '</blockquote',
1 => int 2758
),
5 => Array(
0 => '</blockquote',
1 => int 2794
),
)
running array_reverse($arr) on it, one would expect the returned array to be:
Array (
0 => Array(
0 => '</blockquote',
1 => int 2794
),
1 => Array(
0 => '</blockquote',
1 => int 2758
),
2 => Array(
0 => '</blockquote',
1 => int 2627
),
3 => Array(
0 => '<blockquote',
1 => int 938
),
4 => Array(
0 => '<blockquote',
1 => int 593
),
5 => Array(
0 => '<blockquote',
1 => int 232
),
)
However, it returns an unaltered array. Now, if I do array_reverse($arr[0]), then it reverses the entire array like I want.
I can think of no reason it would not be reversing the initial array, and why, when passing a specific key, it would reverse the entire array, rather than that one sub-array. Why would it be doing this?
EDIT: I walked away and came back, looked at it, and realized the main array had a single element which was the array I'd posted above. Just a good ol' ID-10-T error.