A
A
Andrei St2020-05-10 18:54:34
PHP
Andrei St, 2020-05-10 18:54:34

How to output certain data from json based on true & false parameters?

I extract the data in this way

<?php
$str = file_get_contents ('https://localhost/api.php?ip=127.0.0.1&port=12666'');
$playersonline = json_decode( $str );
echo "<span>";
echo $playersonline->players->now;
echo "</span> игроков";
?>


but in json there is such a line as true and false if the server is disabled, it is displayed false if it is enabled, respectively true how to make it so that the icon is displayed if the server is true if the icon is false?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4sadly, 2020-05-10
@4sadly

$isOnline = $boolean; //boolen - строка из json'a
if($isOnline){
echo 'Сервер онлайн';
}else{
echo 'Сервер офлайн';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question