I am having trouble debugging this? I can't get it to print out the value if it is even or the word "odd" if it is odd? The initial funcitons work but I don't know how to use the array_filter with two conditions? thanks,
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}
function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}
$arr = array(1,2,6,7,9,4,10,11,12,3,13,24);
$keys = array_keys($arr);
for ($counter = 0, $length = count($arr);$counter < $length; $counter++)
{
$key = $keys[$counter];
$value = $array[$key];
if ($arr_filter($arr,'even')==1){
print_r($array[$key];);
}elseif($arr_filter($arr,'odd')==1)
{
print_r('odd');
}
}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 71:49:19 |
Calls: | 8,084 |
Calls today: | 2 |
Files: | 13,069 |
Messages: | 5,849,954 |