I know there's a lot of other questions similar to this one, but I couldn't find any that would apply to my current situation. Here's my code snippet:
<?php
foreach ($configs->servernames as $key => $servertitle) {
$serverip = $configs->serverips[$key];
$serverport = $configs->serverports[$key];
//Server Info Getter
$json = file_get_contents('https://mcapi.us/server/status?ip=' . $serverip . '&port=' . $serverport);
$data = json_decode($json,true);
$onlinestatus = $data['online'];
echo $onlinestatus;
if ($onlinestatus == 1) {
echo 'check_circle';
}
else {
echo 'cancel';
}
echo '
<li>
<div class="collapsible-header"><i class="material-icons">'.
//Online or offline response
if ($onlinestatus == 1) {
echo 'check_circle';
}
else {
echo 'cancel';
}
.'</i>'. $serverip .'</div>
<div class="collapsible-body"><p>Server Info & Status</p></div>
</li>
';
//check_circle is the check icon
} //$servertitle var
?>
I also looked for any missing semicolons or any tags that I might've left open. I have a feeling it has something to do with the fact that I'm pausing the echo and THEN using an if statement.
Here's my issue:
Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\gitrepos\Server-Status\web\index.php on line 38
Also, the EXACT SAME if statement works outside of the echo pause, as seen above it.