filter function with 2 call back functions

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
jlrough
Forum Newbie
Posts: 1
Joined: Thu Jan 04, 2018 5:11 pm

filter function with 2 call back functions

Post by jlrough »

The functions work however I need to iterate an array and if "even" print the array value if "odd" print "odd"; The for loop doesn't print the $i value and it doesn't print "odd" either?
thanks


function odd($var)
{
return($var & 1);
}

function even($var)
{
return(!($var & 1));
}
for ($i=0; $i<= sizeof($arr); $i++){
if ($arr_filter($arr,'even')==1){
print_r($arr=>$i);
}elseif($arr_filter($arr,'odd')==1)
{
print_r('odd');
}
}
Post Reply