posted on mercredi 4 août 2004 14:10 par erebuss

PHP5 tu Sort() >>

TLK: Sort behaviour

John Coggeshall wrote in to say that

<?php
$a
= array('a', 'b', 'c', 'a'=>0, 'b'=>1, 'c'=>2);
      
sort($a);
      
print_r($a);
?>

gives unexpected results, and forgot to attach a patch that would alter this behaviour. Marcus Börger agreed, but pointed out that there were two possible versions of 'expected behaviour', both equally valid. He mailed in a patch for one of those versions. Andi responded that he was concerned the 'fix', whichever direction it took, might break backward compatibility and also affect other functionality, as it actually involves altering the Zend engine's comparison operators. The patch is on hold pending further investigation into these possibilities – or we could just accept that this is how PHP's sort() behaves, and fall back on alternative functions or user-space workarounds to deal with the fact, as of yore.

Marcus went on looking into sort(), and subsequently committed a patch that gives the function a 15% performance increase, while supposedly listening to an OSCON talk about performance. This was one among many performance patches committed during the week, primarily by Marcus and Andi.

Short version: sort() still gives strange results, but now it gives them faster.

J'aime l'humour de la version courte :)
Source : http://www.zend.com/zend/week/week195.php

 

Comments

# re: PHP5 tu Sort() >>

mercredi 4 août 2004 16:59 by David T
Tu as réussi à installer php 5 sous XP pro ou 2003 server sous IIS ????

Moi j'ai abandonné :(

# re: PHP5 tu Sort() >>

mercredi 4 août 2004 17:35 by Erebuss
Leur install est buggé avec IIS sous XP et 2003.
Ils doivent sortir la 5.0.1 en partie pour cette raison.

Perso, j'ai réinstallé un APACHE 2 pour le faire tourner.

# re: PHP5 tu Sort() >>

dimanche 15 août 2004 18:14 by David T
la 5.0.1 est sortie mais ca coince toujours avec IIS :-(