Hi @AMEEKER
Sounds like the issue is not to do with ACF, but more of a general WP question.
I would advise you to ask this question on stack overflow and please debug your function by dumping out the returned data of these if statement functions.
Thanks
E