rob.m rob.m - 1 year ago 61
PHP Question

Name in json has space and doesn't match with a variable

In PHP I do:


That gives me:
United States Of America

In the json I have:

"sovereignt": "United States of America",

The 2 names should match but they don't, I believe is due to the white space in between the words. The reason why I believe that is that if i check with
I have no problems.


I had O instead of O - accepting the answer for future users

Answer Source

It's because O != o (i.e. upper vs. lower case). When doing the comparison, try converting both to lower case (using PHP's strtolower() function):

if( strtolower(the_field('country')) == strtolower($json->soverignt) )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download