I am having issues with using in_array()
inside a foreach
loop. I have an array like this
[0] =>
name=>1
type=>foo
[1] =>
name=>2
type=>bar
[2] =>
name=>3
type=>bar
[3] =>
name=>4
type=>foo
I'm using
if(in_array('foo',$array->type){ *my echo code*}
to take out all array that have type = foo
but it also take out unmatch array. Where am I wrong?