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
}
- 1 回答
- 0 關注
- 174 瀏覽
添加回答
舉報