How to use curl PHP in loop with 100 time?
<p>How to use curl in loop 100 times with send request and store response in an array?</p>

<p>For example : when curl uses in loop first time and gets 500 records and store in an array and again the same process with the second loop and gets 500 records form response  and store in the same array without any issues. Finally, I need store 50K records in the array and I will use for insert records in my database.</p>

<p>I am working last 2 days but not getting any solution for this so please help me.</p>

<pre><code>&lt;?php
$final_data = array();
for($d=1;$d&lt;=100;$d++)
{   
    $data = '{"request": {"header": {"username": "xxx","password": "xxx"},
    "body": {
    "shapes": [],
    "size_to": "",
    "size_from": "",
    "color_from": "",
    "color_to": "",
    "clarity_from": "",
    "clarity_to": "",
    "cut_from": "",
    "cut_to": "",
    "polish_from": "",
    "polish_to": "",
    "symmetry_from": "",
    "symmetry_to": "",
    "labs": [],
    "price_total_from": "",
    "price_total_to": "",
    "page_number": "1",
    "page_size": "50",
    "sort_by": "price",
    "sort_direction": "ASC"
    }}}';

    $json = json_decode($data,true);
    $json['request']['body']['page_number'] = $d;
    $data = json_encode($json); 

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

    curl_setopt($curl, CURLOPT_URL, 'http://technet.rapaport.com/HTTP/JSON/RetailFeed/GetDiamonds.aspx');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    $dd = json_decode($result,true);

    foreach($dd['response']['body']['diamonds'] as $key)
    {       
        array_push($final_data,$key);
    }   
    curl_close($curl);
}
?&gt;
</code></pre>