I have this code:
print ($myarray['response']['players'][0]['VACBanned'] ? 'BANNED' : 'NOT BANNED');
Where "VACBanned" is boolean. But it doesn´t matter if it's 'true' or 'false'; it always gives out "NOT BANNED".
var_dump result: Case 1: 'VACBanned' => bool(true) Case 2: 'VACBanned' => bool(false) Both cases show "NOT BANNED"
PIC: http://i.stack.imgur.com/Rk7uv.png http://i.stack.imgur.com/o0i9f.png
You need to turn error checking on—or check your apache error log—and find the bugs in your code.
For example, your var_dump($myarray);
shows an array that doesn't have any keys of 'response'. However, your print statement is:
print ($myarray['response']['players'][0]['VACBanned'] ? 'BANNED' : 'NOT BANNED');
The array expression can never find anything, as there's no key of "response". So it will (a) be throwing an error "Undefined index: response", and (b) always evaluate to false
, and therefore always say "NOT BANNED".
print (($myarray['response']['players'][0]['VACBanned'] != 0) ? 'BANNED' : 'NOT BANNED');