i have following problem, i generated the urls for the sitemap, in a array. So the array has 60000 entries. And google wants me to create 2 sitemaps cause the limit is 50000 ent
array_chunk is your friend:
$data = array_chunk($data, 50000);
foreach ($data as $key => $value)
{
$cfile = 'sitemap_' . $i . '.xml';
$createfile = fopen($cfile, 'w');
fwrite($createfile, "\n");
fwrite($createfile, "\n");
foreach ($value as $url)
{
$creat = "\n";
$creat .= "" . $url . " \n";
$creat .= "1.00 \n";
$creat .= " \n";
fwrite($createfile, $creat);
}
fclose($createfile);
}
Works with a variable number of sitemaps out of the box.