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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從字符串中獲取數(shù)據(jù)

如何從字符串中獲取數(shù)據(jù)

PHP
富國滬深 2021-11-05 13:25:31
我向 API REST 發(fā)出了 GET 請求,并獲得了一些數(shù)據(jù)(base64 編碼)?,F(xiàn)在我需要從結果中獲得一些特定的值,但我不知道如何。這是我到目前為止<?php    //BUSCAR DOCUMENTOS    $service_url = 'http://192.168.4.77/api/Core.svc/core/PaginatedSearch/P/E/KFRpcG9EVEU6MzMgQU5EIEZjaEVtaXM6WzIwMTktMDYtMjEgVE8gMjAxOS0wNy0zMF0p/0/10';         $ch = curl_init($service_url);    curl_setopt($ch, CURLOPT_URL, $service_url);    curl_setopt($ch, CURLOPT_HTTPHEADER, array(      'AuthKey: top-secret',      'Content-Type: application/json',      'Accept: application/json',    ));    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);    $response = curl_exec($ch);    $err = curl_error($ch);    if ($err) {    echo "cURL Error #:" . $err;    } else {        $datos = json_decode($response,true);        foreach ($datos as $k => $v) {            $Result = $datos['Result'];            $Description = $datos['Description'];            $SearchTime = $datos['SearchTime'];            $TotalDocuments = $datos['TotalDocuments'];            $Data = $datos['Data'];        }        $test = base64_decode($Data);        var_dump($test);    }    curl_close($ch);?>這就是我得到的,需要獲取值(例如:33 2284 21-06-2019 0:00:00)任何幫助將非常感激。
查看完整描述

1 回答

?
冉冉說

TA貢獻1877條經(jīng)驗 獲得超1個贊

看起來數(shù)據(jù)是相當結構化的,即使是一團糟。


好像有一個鍵表示<_DocID>,鍵,值表示<_Group>,值,然后繼續(xù)重復。使用它,我們至少可以將其分解為一個更合理的關聯(lián)數(shù)組。


$structured_response = [];

$keys = explode('<_DocID>', $response); //First we'll look for the keys


foreach ($keys as $key) {

  if ($key == '') continue;

  $data  = explode('<_Group>', $key); //Then we'll look for what's around on either side of the value denotation

  $key   = $data[0]; //Before the key-ending separator will be the key

  $value = $data[1]; //After the separator will be the data


  $structured_response[$key] = $value; //Now save the data to the array

}


查看完整回答
反對 回復 2021-11-05
  • 1 回答
  • 0 關注
  • 174 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號