How do I get the if statement below, to return TRUE and therefore return my string "Africa is in this array"? Note: template is set to parse on INPUT (I cant use output for this template)
<?php
$entryregion="{categories show_group='4' backspace='2'}{category_name}, {/categories}";
$entryregionArr=(explode(',',$entryregion));
print_r($entryregionArr);
echo "<br />" ;
if (in_array('Africa', $entryregionArr)) {
echo "Africa is in this array";
}
?>
the above print_r($entryregionArr);
prints an array that looks like this. Array ( [0] => Africa [1] => South Africa [1] => Durban [1] => )
I think I want it to look more like this Array ( [0] => Africa [1] => South Africa [2] => Durban )
where Durban is in the 2nd key and the last key id deleted, but I am not sure why or how to do this. I have tried parse='inward'
in the category tag. I had a recent suggestion through this site to use the explode() function and I am grateful because it has shown me that this is where my error is. Well, one step at a time. Any suggestions would be appreciated.