I wrote a sorting function to use with usort(). It worked fine, and I
went on with the development of my code. At one point I changed the name
of the sorting function, but forgot to update it in the usort() call.
Yet, it still was working. I removed the usort() call to make sure my
data didn't just happen to be arriving in sorted order, and it wasn't.
When I removed the usort() call, the code broke; when I put it back, it
worked. I changed the name of the callback function in the usort() call
to random letters, and it still worked. How is this possible? Does usort
"remember" the last valid sorting algorithm it had? To test this wild
hypothesis, I uploaded the code to a server where it had never run. It
still works. WTH?
The elements of the array I'm sorting are each an array with two
elements, and I'm sorting on the second element, in reverse order. Is
this the default behavior for usort() if it can't find the callback
function? This is really bizarre. Anyone know what's going on?
--
Alan Little
Phorm PHP Form Processor
went on with the development of my code. At one point I changed the name
of the sorting function, but forgot to update it in the usort() call.
Yet, it still was working. I removed the usort() call to make sure my
data didn't just happen to be arriving in sorted order, and it wasn't.
When I removed the usort() call, the code broke; when I put it back, it
worked. I changed the name of the callback function in the usort() call
to random letters, and it still worked. How is this possible? Does usort
"remember" the last valid sorting algorithm it had? To test this wild
hypothesis, I uploaded the code to a server where it had never run. It
still works. WTH?
The elements of the array I'm sorting are each an array with two
elements, and I'm sorting on the second element, in reverse order. Is
this the default behavior for usort() if it can't find the callback
function? This is really bizarre. Anyone know what's going on?
--
Alan Little
Phorm PHP Form Processor
Comment