How to skip images that http status 404 or 401? How to skip images that http status 404 or 401? curl curl

How to skip images that http status 404 or 401?


Try this:

$ch = curl_init($image);curl_setopt($ch,  CURLOPT_RETURNTRANSFER, TRUE);$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);if($httpCode != 404) //# if error code is not "404"{    /* Your Function here. */}else {    /* Handle 404 here. */}


Try setting an array of http codes, like:

$httpCodes = [401,404];

And than just check:

  if(!in_array(CheckLinkStatus($image),$httpCodes){        // YOur logic    }   else {        // Handle 401 && 404    }