I have a large database of remote mp3 urls of various websites both old and new. I am using the following code to check whether the urls are valid mp3 or not in php
function check_url($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
if($headers['content_type']=='audio/mpeg'&&$headers['http_code']=='200')
return 1;
else
return 0;
}
It is consuming huge execution time. Can anybody suggest any other alernative to perform this task.