John Chase John Chase - 1 year ago 88
JSON Question

PHP JSON If or Else

I'm trying to write a PHP script so if the network type is a JSON feed, I'm pulling indicates mobile event is triggered and if not another event is triggered. I can't figure out the if or else, I've tried a bunch of variations.


echo( "Network Type: " . $decoded_response['current_carrier']['network_type']);
if ($decoded_response['current_carrier']['network_type']) = 'mobile') {
echo "Event1";
} else {
echo "Event2";

Answer Source
if ($decoded_response['current_carrier']['network_type']) = 'mobile'){

maybe this should be

if ($decoded_response['current_carrier']['network_type'] == 'mobile'){

You are using single = instead of == to check for equality. = would assign and not test.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download