I have the following code that looks through the category array and finds the existence of the string 'Events'. I want only it to trigger if there is NOT an array entry called "Events", something like for example 'News and Events' is fine. I'm sure it's a simple solution but I can't seem to find it. Any thoughts?
$cat_check = get_the_category_list(',');
$cat_check_array = explode(",",$cat_check);
if(!(in_array("Events", $cat_check_array, true))) {
//Do Something
}
Example of categories in $cat_check
$cat_check = "News and Events","Category 1","Category 2";
$cat_check = "Events";
The only thing I don't want this bit of code to trigger on is the existence of an array entry "Events", anything else like "News and Events" is perfectly fine.
Eventsis NOT in the array. IfNews and Eventsis in the array but not justEventsthen the IF is true.