Bug #14591: uasort mixes array with equal elements

From: Date: Tue, 18 Dec 2001 22:03:19 +0000
Subject: Bug #14591: uasort mixes array with equal elements
Groups: php.dev 
Request: Send a blank email to php-dev+get-74316@lists.php.net to get a copy of this message
From: jan@horde.org Operating system: Linux/Windows PHP version: 4.1.0 PHP Bug Type: Arrays related Bug description: uasort mixes array with equal elements If you call uasort with a function that always returns 0 (elements equal) you get a totally screwed array returned. <?php function mysort($a, $b) { return 0; } $a = array('h', 's', 'i', 'c', 'q', 'm'); var_dump($a); uasort($a, 'mysort'); var_dump($a); ?> returns: array(6) { [0]=> string(1) "h" [1]=> string(1) "s" [2]=> string(1) "i" [3]=> string(1) "c" [4]=> string(1) "q" [5]=> string(1) "m" } array(6) { [1]=> string(1) "s" [2]=> string(1) "i" [3]=> string(1) "c" [4]=> string(1) "q" [5]=> string(1) "m" [0]=> string(1) "h" } -- Edit bug report at: http://bugs.php.net/?id=14591&edit=1

« previous php.dev (#74316) next »