我正在使用Wufoo api(https://{subdomain}.wufoo.com/api/v3/forms/{formIdentifier}/entries.{xml|json})嘗試將我所有的條目(當前爲150左右)作爲一個php數組。 Wufoo限制返回到100的條目數。所以現在我有兩個php數組,我想將它們連接/組合成一個數組。連接Wufoo API結果
到目前爲止的代碼:
$api_uri_1 = "https://example.wufoo.com/api/v3/forms/example-form/entries.json?pageStart=0&pageSize=100";
$api_uri_2 = "https://example.wufoo.com/api/v3/forms/example-form/entries.json?pageStart=1&pageSize=100";
function wufoo_api($api_uri) {
$curl = curl_init($api_uri);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, 'WUFOO-API-KEY-HERE:password');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_USERAGENT, 'Wufoo Sample Code');
$response = curl_exec($curl);
$resultStatus = curl_getinfo($curl);
if ($resultStatus['http_code'] == 200) {
$results = json_decode($response, true);
return $results;
} else {
$results = 'Call Failed '.print_r($resultStatus);
return $results;
}
}
$result1 = wufoo_api($api_uri_1);
$result2 = wufoo_api($api_uri_2);
我已經試過,也沒有工作
$all_results = array_merge($result1, $result2);
和這樣的事情
$all_results = $result1;
$all_results += $result2;
如何CA n個I串聯/提前任何幫助
更新相結合RESULT1和RESULT2
感謝:什麼工作
感謝Ben我意識到我需要使用數組鍵爲目標的部分我需要的陣列。
$all_results = array_merge($result1['Entries'],$result2['Entries']);
請參閱下面我的答案中的意見,我不認爲你的更新是有道理的.. – Ben
我糾正它,謝謝本。 – michaelespinosa