PHP Search entries according to year indexed

EDITED: It was a simple mistake. I changed the "=" to "===" in the if statement and it works.