After hours of debugging, I have finally determine that for some reason on a particular web-server running my small script, two equal strings are apparently being interpreted as
Why don't you try using trim in your trim($data[0]); and compare it.
Use trim() (note the second parameter, which accepts other chracters like ";" in your case) and strtolower()
or strtoupper()
on both strings just before comparision.
Also, if you have the option to change the API response, try implementing a JSON response instead of returning a plain string. It will be less memory intensive and more maintainable.