one line best solution :
echo array_change_key_case(get_headers("http://.../file.txt",1))['content-length'];
php is too delicius
function urlsize($url):int{
return array_change_key_case(get_headers($url,1))['content-length'];
}
echo urlsize("http://.../file.txt");