So I have two arrays:
$gated_categories
array(2) { [0]=> int(3511) [1]=> int(3510) }
and
$category_id
array(3) { [0]=> int(3518) [1]=> int(3511) [2]=> int(3502) }
As you can see above, both arrays contain 3511
So if $gated_categories contains a value which is is $category_id
I want this to return true, else false
I have tried with this:
$is_gated = !array_diff($gated_categories, $category_id);
But this is returning false, any ideas?
$ithe samearray_diffreturns the difference between two arrays, but you are negating the obtained result, that's why you are obtaining a boolean value. Usearray_intersectinstead.