I need to be able to test if $post_count is equal to any number in a given array. Here is an example of what I am trying to achieve:
$posts_even = array(2,4,6,8,10);
$posts_odd = array(1,3,5,7,9);
$posts_ev3 = array(1,4,7,10);
$posts_ev4 = array(1,5,9);
—
$post_count=1;
$post_count=++; //in wordpress loop so each subsequent post is +1
—
if ($post_count= //any value in $posts_ev4) :
echo 'this'
else :
NULL;
endif;
I have been able to make this work using the or operator but I end up with very long blocks of code…..
if (($post_count=1) || ($post_count=2)) :
echo 'this'
else :
NULL;
endif;
I am guessing there is a simpler way to do this but I am new to PHP so I am not sure! Any help would be greatly appreciated.
Try:
See: in_array()