php.net user-contributed notes
Does anyone know what's up with these? I tried to add a note to array_filter and while it said it accepted it, hours later it's not updated anywhere. I had to use this function inside a class I'd written and couldn't quite get it cooperate with a method callback until I was able to learn from someone else's code (page 6 of a google search).
<?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);
}
}
?>
<?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);
}
}
?>
