假設我透過curl, 對方透過json來我這直接給我一千筆數據
但這樣一次出現一千筆似乎不太對?如何透過php方式實現一頁20筆?有範本可參考?謝謝!
一點頭緒也沒有
function httpRequest ($api, $data_string)
{
$ch = curl_init($api);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result);
}
$x = array(
"session" => $_SESSION['session']
);
$x_string = json_encode($x);
$x = httpRequest($api, $x_string);
我是這樣取對方的數據的,只是要怎麼....做分頁?
慕运维8079593
杨魅力
繁花如伊
阿晨1998
慕少森
炎炎设计