0
Hello, I’m here to ask for your help, I have a job to do with pure PHP and an API provided by the company, and the part I stopped was where I need to do online and offline status by changing the background of using pure PHP or javascript, also need to make users are online users who are provided by the API do not repeat themselves within the foreach, and those who are online get the green color in the background, and those offline get the gray color
CODE
<div class="row row row-cols-2 row-cols-lg-10 g-2 g-lg-3 row-aling-ramal" id="chat">
<?php
//Consumindo as APIs
$urlUsers = "http://191.252.93.122/users.php";
$resultadoUrlUsers = json_decode(file_get_contents($urlUsers));
$urlUsersOnline = "http://191.252.93.122/usersonline.php";
$resultadoUrlUsersOnline = json_decode(file_get_contents($urlUsersOnline));
$urlAgenda = "http://191.252.93.122/addressbook.php";
$resultadoUrlAgenda = json_decode(file_get_contents($urlAgenda));
//LOOP PARA IMPRIMIR OS DADOS DO ARRAY DA API
//dois foreach repete o array trazendo os usuarios, e os usuarios online
foreach ($resultadoUrlUsers as $atorUser):
//foreach($resultadoUrlUsersOnline as $atorUsersOnline):
//tentativa de fazer validação do background
//$cinza = 'bg-grey';
/*if(strcmp("Available", $atorUser->status) == 0){
$color = 'bg-green';
}else{
$color = 'bg-grey';
}*/
?>
<div class="col-sm col-aling-ramal">
<span class="badge rounded-pill border-span bg-green span-format-info font-color-black">
<?php
//echo substr($atorUser->name, 0, 4);
$ids = $atorUser['name'];
echo $ids;
?>
</span>
</div>
<br>
<?php
endforeach;
//endforeach;
?>
</div>
</div>