我想獲取最后在 Veeam 中輸入的公司名稱的實(shí)例 ID 并將其保存在我的數(shù)據(jù)庫(kù)中我正在使用 Curl 作為 APi at Rest 。下面的代碼獲取響應(yīng)并對(duì)其進(jìn)行解碼$response = curl_exec($curl);$json = $response;$json_output = json_decode($json, true);echo '<pre>';print_r($json_output); 響應(yīng)如果低于Array( [meta] => Array ( [pagingInfo] => Array ( [total] => 7 [count] => 7 [offset] => 0 ) ) [data] => Array ( [0] => Array ( [instanceUid] => 0aa2db5f-3450-4c30-8074-c215ca509475 [name] => Jerome_Company [status] => active [resellerUid] => [subscriptionPlanUid] => a8078b36-c29b-40db-90f5-4960a05fff1e [permissions] => Array ( ) ) [5] => Array ( [instanceUid] => ebcd92e9-bb13-4ea0-87c4-175bc7b5ab1f [name] => Xoagub [status] => active [resellerUid] => [subscriptionPlanUid] => a8078b36-c29b-40db-90f5-4960a05fff1e [permissions] => Array ( ) ) [6] => Array ( [instanceUid] => 1325d332-b7d9-4960-9004-0b7ca335078e [name] => Gmail [status] => creating [resellerUid] => [subscriptionPlanUid] => a8078b36-c29b-40db-90f5-4960a05fff1e [permissions] => Array ( ) ) ))有沒有一種方法可以獲取上次進(jìn)入公司的instanceUid?
1 回答

猛跑小豬
TA貢獻(xiàn)1858條經(jīng)驗(yàn) 獲得超8個(gè)贊
獲取最后一個(gè)條目data
,然后獲取instanceUid
:
echo end($json_output['data'])['instanceUid'];
但是你不應(yīng)該在任何地方嘗試從非對(duì)象中獲取值,除非你嘗試像這樣的對(duì)象來(lái)訪問某些東西$json_output->data
;這不起作用,因?yàn)槟呀獯a為true
傳遞給的數(shù)組json_encode
。
- 1 回答
- 0 關(guān)注
- 117 瀏覽
添加回答
舉報(bào)
0/150
提交
取消