for döngüsü ile yapsan ?
for ($i = 10; $i < 5001; $i++)
{
$ac = file_get_contents("http://adres.com/ali/".$i);
}