PHP if you call API content to display on a web page

call API: https://api.mcsrvstat.us/quer...:19132

return data

{"HostName":"DCPE","GameType":"SMP","GameName":"MINECRAFTPE","Version":"v1.8.0","Plugins":["BlockPets 1.1.2","iProtector 1.0.0-BETA","CombatLogger 0.0.5","VoteReward 3.0.3","ASR 2.0.3","DevTools 1.13.0","PiggyCrates 1.2.0","TeaSpoon 1.0.1","GrabBag 2.4.3","Broadcaster 1.5","ApiUpdaterDP 3.1.0","Hats 1","OreAboveEndStone 1.0.0","TierLoot 1.0.0","ForceFac 1.0.0","Functions 1.2.1","SetBlock 1.0.0","Limiter 0.0.1","ClearLagg 1.1.0","BuycraftPM 0.5.1","DimensionsPE 1.0.0","HotBlock 1.1.3","JoinCommands 1.5","VanillaEnchantments 3.1.0_ALPHA","CustomSetting 1.0.1","PurePerms 1.4.2","WarpUI 1.1","AdvancedFly 1.8.1","Overvoltage 1.0.0","BlockCmdPE 1.0.0","PvPLevels 1.0","CreativeItemsPlus 1.0.2","CobaltGuns 1.2.0","EconomyAPI 5.7.2","CosmicAxe 1.0.0","CoinFlip 1.0.0","ManyWorlds 2.1.0","essentialsTP 1.2.1","PiggyCustomEnchants 1.2.0","CommandShop 1.0.0","FactionsPro 1.3.11-3","PureChat 1.4.11","PureChatExtras 0.1.0"],"Map":"Caleum","Players":0,"MaxPlayers":40,"HostIp":"0.0.0.0","HostPort":19132,"RawPlugins":"PocketMine-MP 3.5.2: BlockPets 1.1.2; iProtector 1.0.0-BETA; CombatLogger 0.0.5; VoteReward 3.0.3; ASR 2.0.3; DevTools 1.13.0; PiggyCrates 1.2.0; TeaSpoon 1.0.1; GrabBag 2.4.3; Broadcaster 1.5; ApiUpdaterDP 3.1.0; Hats 1; OreAboveEndStone 1.0.0; TierLoot 1.0.0; ForceFac 1.0.0; Functions 1.2.1; SetBlock 1.0.0; Limiter 0.0.1; ClearLagg 1.1.0; BuycraftPM 0.5.1; DimensionsPE 1.0.0; HotBlock 1.1.3; JoinCommands 1.5; VanillaEnchantments 3.1.0_ALPHA; CustomSetting 1.0.1; PurePerms 1.4.2; WarpUI 1.1; AdvancedFly 1.8.1; Overvoltage 1.0.0; BlockCmdPE 1.0.0; PvPLevels 1.0; CreativeItemsPlus 1.0.2; CobaltGuns 1.2.0; EconomyAPI 5.7.2; CosmicAxe 1.0.0; CoinFlip 1.0.0; ManyWorlds 2.1.0; essentialsTP 1.2.1; PiggyCustomEnchants 1.2.0; CommandShop 1.0.0; FactionsPro 1.3.11-3; PureChat 1.4.11; PureChatExtras 0.1.0","Software":"PocketMine-MP 3.5.2","PlayerList":false}

I want to get some data and display it on the PHP web page. What do I need to do? Thank you very much.

Php
Apr.28,2022


PHP @qiaoweizhen

<strong></strong>

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.mcsrvstat.us/query/DCPE-Play.cf:19132",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET"
));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

if ($err) {
  // 
  // echo "cURL Error -sharp:" . $err;
} else {
    $response = json_decode($response, true);
}

data assignment (this is handled differently according to different frameworks, here is an example of thinkphp)

$this->assign("response", $response);

Page processing (with template engine)

<!--  HostName  -->
<div><?php echo $response['HostName']; ?></div>

<!--  Plugins  -->
<?php foreach ($response['Plugins'] as $value) { ?>
    <?php echo $value; ?>
<?php } ?>

Page processing (in direct echo html code form)

//  HostName 
echo "<div>{$response['HostName']}</div>";

//  Plugins 
foreach ($response['Plugins'] as $value) {
    echo "<li>{$value}</li>";
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea4ae8-1cf7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea4ae8-1cf7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?