Re: usort to a Object

From: Date: Wed, 11 Oct 2000 15:45:37 +0000
Subject: Re: usort to a Object
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-19615@lists.php.net to get a copy of this message
Hi Juan: > class b { > var name; > function b($na) { > $this->name=$va; Needs to be "var $name;" and "$this->name=$na;" Of course, you may be giving a terse example, but your example should work. I copied and pasted your code and it's got tons of syntax errors. Makes helping you harder. > var MiArray = Array(); This line produces a parse error on PHP 4.0.2. > function ups() { > array_push(new b("Juan")); > array_push(new b("Carlos")); Your syntax for array_push is wrong. You need to have at least two arguments, one being an array, the other being new items to add to the array. > usort($this->MiArray,$this->sort_user); The function name argument in usort() needs to be a string, not the name of the function itself, so try this: usort($this->MiArray,"this->sort_user"); Rework your code and try it out. There may be other problems I didn't catch off hand. --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y More than just answers. Solutions. (SM) http://www.analysisandsolutions.com/ 4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.general (#19615) next »