Answer the question
In order to leave comments, you need to log in
How to split a sitemap?
There are 50 thousand links, how to split them using php into separate sitemap files of 5 thousand each and create a main one in which all these files will be listed? You can even article if there is, I did not find anything
Answer the question
In order to leave comments, you need to log in
$array= Array([0] => Array ( [name] => 1699 ) ,[1] => Array ( [name] => 1669 )) // масив намного длиней но структура однотипная
$num = 0;
$col = 5000;
$val = $col;
$sum = count($array);
$cel = (intdiv($sum, $col) * $col);
$ost = $sum - $cel;
foreach($array as $i => $value):
if ($i < $val){
print base_url("watch/".$value['name'].".html")."<br>";
}else{
print '<br>';
print '<br>';
if ($i >= $cel){
$val = $val + $ost - 1;
}else{
$val = $val + $col;
}
}
endforeach;
https://github.com/KarelWintersky/kwTools.SitemapG...
And don't reinvent the wheel. It has already been invented before you.
I recommend a personal service https://seospeciali.st/sitemap-split/
You can submit files with URLs in .txt, .xls or .xlsx formats or directly a sitemap in .xml format
Limit ~ up to 100k URLs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question