jdog
jdog

Reputation: 2549

using splheap in php 5.2

Is there any way to use splheap in php 5.2? Ie. could I paste the classes somewhere? Specifically I want to use it to sort items in an iterator, I'm looking for the equivalent of usort() on an iterator.

Upvotes: 1

Views: 477

Answers (1)

Pascal MARTIN
Pascal MARTIN

Reputation: 401142

SplHeap (as other classes provided by PHP itself) is not coded in PHP.

It is actually coded in C -- as the rest of PHP itself -- and, as such, cannot just be copy-pasted to your project.


The only way you'd have of getting those classes into PHP 5.2 would be to :

  • Get the sources of PHP 5.3
  • Get the sources of PHP 5.2
  • Do some kind of merge between those -- merging the definitions of SplHead, and all it can depend upon
  • And compile your own version PHP 5.2 + those merges

This doesn't seem like quite an easy task ; and I would not recommend doing it : your PHP code would only be able to work with your own version of "PHP 5.2+merges".


Instead, considering that PHP 5.2 has reached his end of life, it would be much wiser to upgrade to PHP 5.3.

Upvotes: 3

Related Questions