@No4NaMe

Как вывести данные из json в php страницу?

{"servers":{"www:19132":{"ping":0,"names":[""],"motd":"aMCraftf.pw lv3.0 bvk.com\/mcraft_pw","type":"SMP","game":"MINECRAFTPE","version":"v1.14.0","plugins":"PocketMine-MP 3.11.4: ItemCloud 1.3.1; MineReset 3.3.0; FormAPI 1.3.0; SkyBlock 3.0.0; MultiWorld 1.5.2; AllSigns 1.0.12; WelcomeMessage 1.0.0; BuilderTools 1.2.0-beta2; MapImageEngine 1.1.3; AutoMineReset 0.3.4; PurePerms 1.4.2; DevTools 1.13.5; CompassXYZ 1.0; ChatMuffler 1.0.2; EconomyPShop 2.0.3; Broadcaster 1.5; MOTDShuffle 1.1.7; essentialsTP 1.2.2; BadWordBlocker 1.2.8; SimpleAuth 2.1.3; KillHealth 1.0.0; LightningDeath 1.0.1; StarterKit 1.0.1; MysteryCrate 9.1.1; Parkour 1.5.7; Texter 3.4.4; AuthUI 1.0.0; Slapper 1.5.2; SexGuard 1.1.9; Jail 1.3.0; PiggyCustomEnchants 2.0.4; PureEntitiesX 0.6.3; ScoreHud 5.1.1; MSpawns 2.2; AdvancedJoin 1.1.0; EconomyAPI 5.7.2; PureChat 1.4.11; AdvancedKits 5.3.0; EconomySell 2.0.10; KillMoney 1.0.0-stable; CustomShopUI 4.0.5; PiggyCustomEnchantsShop 1.3.1; EconomyLand 2.1.2; EconomyJob 2.0.5; PlayerHead 1.3; MagicTelePortal 1.3.5; TopMoney 1.0.0; KisayolTP 2.5; FloatingText 1.0.0; SlapperRotation 1.2.1; ExampleUI 1; PCFly 3.0.0; TicTacToe 0.1.5; MiniBosses 2.0.2; 1vs1 1.0.1; VanishV2 1.4; FactionsPro 1.3.20; SkyWars 1.2.0; SkyWars-Reward 1.1.2","map":"Castle","online":"0","slots":"200","status":"online","address":"191.168.0.01:19132","percent":0}},"online":0,"slots":200,"percent":0,"timerec":"25 \u044f\u043d\u0432\u0430\u0440\u044f \u0432 13:53","record":942,"recordday":0,"timerecday":"01:22"}


Подскажите как из базы json вывести данные "online":"0", "record":0," в php для отображения. Данная функция отвечает за вывод количество онлайн игроков и его рекорда!
  • Вопрос задан
  • 232 просмотра
Решения вопроса 1
glaphire
@glaphire Куратор тега PHP
PHP developer
$json = '{"servers":{"www:19132":{"ping":0,"names":[""],"motd":"aMCraftf.pw lv3.0 bvk.com\/mcraft_pw","type":"SMP","game":"MINECRAFTPE","version":"v1.14.0","plugins":"PocketMine-MP 3.11.4: ItemCloud 1.3.1; MineReset 3.3.0; FormAPI 1.3.0; SkyBlock 3.0.0; MultiWorld 1.5.2; AllSigns 1.0.12; WelcomeMessage 1.0.0; BuilderTools 1.2.0-beta2; MapImageEngine 1.1.3; AutoMineReset 0.3.4; PurePerms 1.4.2; DevTools 1.13.5; CompassXYZ 1.0; ChatMuffler 1.0.2; EconomyPShop 2.0.3; Broadcaster 1.5; MOTDShuffle 1.1.7; essentialsTP 1.2.2; BadWordBlocker 1.2.8; SimpleAuth 2.1.3; KillHealth 1.0.0; LightningDeath 1.0.1; StarterKit 1.0.1; MysteryCrate 9.1.1; Parkour 1.5.7; Texter 3.4.4; AuthUI 1.0.0; Slapper 1.5.2; SexGuard 1.1.9; Jail 1.3.0; PiggyCustomEnchants 2.0.4; PureEntitiesX 0.6.3; ScoreHud 5.1.1; MSpawns 2.2; AdvancedJoin 1.1.0; EconomyAPI 5.7.2; PureChat 1.4.11; AdvancedKits 5.3.0; EconomySell 2.0.10; KillMoney 1.0.0-stable; CustomShopUI 4.0.5; PiggyCustomEnchantsShop 1.3.1; EconomyLand 2.1.2; EconomyJob 2.0.5; PlayerHead 1.3; MagicTelePortal 1.3.5; TopMoney 1.0.0; KisayolTP 2.5; FloatingText 1.0.0; SlapperRotation 1.2.1; ExampleUI 1; PCFly 3.0.0; TicTacToe 0.1.5; MiniBosses 2.0.2; 1vs1 1.0.1; VanishV2 1.4; FactionsPro 1.3.20; SkyWars 1.2.0; SkyWars-Reward 1.1.2","map":"Castle","online":"0","slots":"200","status":"online","address":"191.168.0.01:19132","percent":0}},"online":0,"slots":200,"percent":0,"timerec":"25 \u044f\u043d\u0432\u0430\u0440\u044f \u0432 13:53","record":942,"recordday":0,"timerecday":"01:22"}';
json_decode($json, true)['online'];
json_decode($json, true)['record'];

Документация на json_decode.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы