【发布时间】:2016-03-02 01:08:40
【问题描述】:
我正在尝试解析从服务器到数组的 JSON 响应,但它不起作用。
我在用:
json_decode($string,true);
所以这一定不是问题。
这是我询问服务器的代码:
$curl_header = array();
$curl_header[] = "Authorization: Basic ".base64_encode("$auth_code:");
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $curl_header);
curl_setopt($curl, CURLOPT_URL, 'https://api.kassacompleet.nl/v1/ideal/issuers/');
$result = curl_exec($curl);
curl_close($curl);
// Handle and store result
$test = json_decode($result, true);
print_r($test);
这是我在打印后从服务器得到的响应:
[ { "id": "INGBNL2A", "list_type": "Nederland", "name": "Issuer Simulation V3 - ING" }, { "id": "RABONL2U", "list_type": "Nederland", "name": "Issuer Simulation V3 - RABO" } ]1
这个奇怪的 nr 1 在我打印后出现在字符串的末尾。
有人对我有什么建议吗?
【问题讨论】:
标签: php arrays json curl server