PHPverse 2025

Voting

: min(six, three)?
(Example: nine)

The Note You're Voting On

cross+php at distal dot com
17 years ago
In response to "rune at zedeler dot dk"s comment about class contents being equal, I have a similar issue. I want to sort an array of objects using sort().

I know I can do it with usort(), but I'm used to C++ where you can define operators that allow comparison. I see in the zend source code that it calls a compare_objects function, but I don't see any way to implement that function for an object. Would it have to be an extension to provide that interface?

If so, I'd like to suggest that you allow equivalence and/or comparison operations to be defined in a class definition in PHP. Then, the sorts of things rune and I want to do would be much easier.

<< Back to user notes page

To Top