第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在 PHP 中從 JSON 獲取單個(gè)項(xiàng)目

在 PHP 中從 JSON 獲取單個(gè)項(xiàng)目

PHP
蝴蝶不菲 2023-07-01 17:32:04
我已經(jīng)搜索了堆棧溢出,但沒(méi)有找到我想要做什么...所以這里的問(wèn)題是: 如何僅返回 STEAMID?代碼:<?php// define variables and set to empty values$steamID = "";if ($_SERVER["REQUEST_METHOD"] == "POST") {  $steamID = test_input($_POST["steamID"]);}function test_input($data) {  $data = trim($data);  $data = stripslashes($data);  $data = htmlspecialchars($data);  return $data;}$keyApp = '5DE00EE4D07BA728EDAB0B3C2961AA6B';$api = "";$json_data = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$keyApp&steamids=$steamID");$array = json_decode($json_data, true);var_dump($array);?>var_轉(zhuǎn)儲(chǔ):array(1) {  ["response"]=>  array(1) {    ["players"]=>    array(1) {      [0]=>      array(19) {        ["steamid"]=>        string(17) "76561198058543756"        ["communityvisibilitystate"]=>        int(3)        ["profilestate"]=>        int(1)        ["personaname"]=>        string(12) ""Cientistas""        ["commentpermission"]=>        int(1)        ["profileurl"]=>        string(37) "https://steamcommunity.com/id/rhatto/"        ["avatar"]=>        string(116) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/c9/c9442f1ea597a7685f8e50f2f7c922321beb4eba.jpg"        ["avatarmedium"]=>        string(123) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/c9/c9442f1ea597a7685f8e50f2f7c922321beb4eba_medium.jpg"        ["avatarfull"]=>        string(121) "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/c9/c9442f1ea597a7685f8e50f2f7c922321beb4eba_full.jpg"        ["avatarhash"]=>        string(40) "c9442f1ea597a7685f8e50f2f7c922321beb4eba"        ["lastlogoff"]=>        int(1593317334)        ["personastate"]=>        int(0)
查看完整描述

2 回答

?
Helenr

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超4個(gè)贊

通過(guò)訪(fǎng)問(wèn)唯一的正確路徑steamid,顯然玩家數(shù)組中可能有多個(gè)項(xiàng)目。所以你可能需要某種循環(huán)。


也許是這樣的:


$players = $array['response']['players'];


foreach($players as $player) {

  echo $player['steamid'] . '<br>';

}

或者,如果你的玩家數(shù)組中總是有 1 個(gè)玩家,你也可以這樣做(快速而骯臟):


echo $array['response']['players'][0]['steamid'];


查看完整回答
反對(duì) 回復(fù) 2023-07-01
?
BIG陽(yáng)

TA貢獻(xiàn)1859條經(jīng)驗(yàn) 獲得超6個(gè)贊

$steamID = $array['response']['players'][0]['steamid'];



查看完整回答
反對(duì) 回復(fù) 2023-07-01
  • 2 回答
  • 0 關(guān)注
  • 187 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)