function vidCheck($vid) { $url = 'https://img.youtube.com/vi/'.$vid.'/0.jpg?fresh='.time(); $headers = get_headers($url); return (substr($headers[0], 9, 3) == 200) ? true : false; } // usage; video id from url: https://www.youtube.com/watch?v=z3PpphdrEmU // echo vidCheck('z3PpphdrEmU');