I need to use curl_multi to get http codes from urls but my code is not working. I am able to scan urls but curl_getinfo always returns 0. i tried without multi api but then checking takes forever
$i = 0;
$ch = curl_multi_init();
while($i < count($cat_and_id)){
$link = explode("_", $cat_and_id[$i]);
$cat = $link[0];
$post_id = $link[1];
$link = "https://website.com/item/?cat=".$cat."&post_id=".$post_id;
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_multi_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code !== 301) {
echo $code;
}
$i++;
}
curl_multi_close($ch);