note 40135 added to function.array-filter

From: Date: Mon, 23 Feb 2004 09:27:10 +0000
Subject: note 40135 added to function.array-filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-65574@lists.php.net to get a copy of this message
An anonymous fellow tried to provide an example of using a class method as the callback for array_filter() and confused it toward the end by changing the method name. Here's a straightforward code snippet: <?php class testclass { function testclass() { // define the numbers array $numbers = array(1, 2, 3, 4, 5, 6); // pull out the odd numbers $odd = array_filter($numbers, array($this, "odd")); // pull out the even numbers $even = array_filter($numbers, array($this, "even")); } function odd($var) { return($var % 2 == 1); } function even($var) { return($var % 2 == 0); } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-filter.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40135 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40135&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40135&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65574) next »