#22847 [Opn->Fbk]: Reference don't work in sort callbacks

From: Date: Wed, 23 Apr 2003 09:53:21 +0000
Subject: #22847 [Opn->Fbk]: Reference don't work in sort callbacks
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-38196@lists.php.net to get a copy of this message
 ID:               22847
 Updated by:       sniper@php.net
 Reported By:      jparneodo at yahoo dot fr
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: RH7.2
 PHP Version:      4.3.0
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2003-03-24 06:19:35] jparneodo at yahoo dot fr

function cmp($a,$b){
	global $g;
	var_dump($g);	// NULL here
	if($g[$a]>$g[$b]){
		return -1;
	}elseif($g[$a]<$g[$b]){
		return 1;
	}else{
		return 0;
	}
}
class A {
	var $aa=array('B'=>2,'A'=>1,'C'=>3);
	function sortme(){
		global $g;
		$g=&$this->aa;
		uksort($g,'cmp');
	}
}
$a=new A;
$a->sortme();		// Don't work

$g=&$a->aa;
uksort($g,'cmp');	// Work


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22847&edit=1



Thread (6 messages)

« previous php.bugs (#38196) next »