Re: reference a function in a class from array_walk()
| From: | Leif K-Brooks | Date: | Sat, 21 Jun 2003 22:47:23 +0000 |
| Subject: | Re: reference a function in a class from array_walk() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152412@lists.php.net to get a copy of this message | ||
Thomas Hochstetter wrote:
Hi guys. I want to call this generic echo function within a class, but have trouble referencing the output function with $this-> . Any suggestions? Maybe there is a better solution to this? This is within a class: [snip] # generic WALK functions"A method of an instantiated object is passed as an array containing an object as the element with index 0 and a method name as the element with index 1." function walkit($array){ array_walk($array,array($this,'output')); } function output($item,$key){ echo "$key. $item<br />\n"; } -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.function walkit($array) { array_walk($array,"$this->output"); //notworking} function output($item,$key) { echo "$key. $item<br />\n"; }thomas http://us3.php.net/manual/en/language.pseudo-types.php