John Chase John Chase - 4 months ago 7x
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";

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.