for ($i = 1; $i < count($ad_counter); $i++) { $c_url = curl_init(); curl_setopt($c_url, CURLOPT_URL, "https:/example.com/page=".$i); curl_setopt($c_url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($c_url, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c_url, CURLOPT_POST, 0); curl_setopt($c_url, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c_url, CURLOPT_COOKIEFILE, "cookie.txt"); $response = (curl_exec($c_url)); curl_close($c_url); $html = new simple_html_dom(); $html -> load($response); foreach($html->find('div.zi2') as $an){ $item['id'] = $an->find('input.checkbox', 0)->value; $ans[] = $item; } }