mardi 7 juin 2016

Echo specific array items and use them in a if else statement

I am busy creating a on and off switch based on an item in an array.

The array is created from an API, and is returned in JSON.

$json = file_get_contents($url);

$data = json_decode($json,true);

print_r($data);

The print_r result is this:

Array ( 
    [GetDeviceListResult] => Array ( 
        [Devices] => Array ( 
            [0] => CanvasControllerDeviceCanvas Controller 1 
            [1] => LaCie 324 (2- Intel(R) Display 
            [2] => Realtek Digital Output (2- Real 
            [3] => SchedulerDevice 
            [4] => SneakerNetDevice 
            [5] => SystemDevice 
        )
        [ServiceStatus] => Success 
    ) 
)

Signs4u

Let's say, i want the ServiceStatus. If its Success, make a green button, if its failure, make it a red button.

How do I accomplish this?

Aucun commentaire:

Enregistrer un commentaire