I have the following problem: I created the url for the sitemap in the array. Thus, the array has 60,000 entries. And google wants me to create 2 Sitemaps because the limit is 50,000 entries in each sitemap.
How can I do this with php? I tried, but I have problems with the loop to stop and enter other data into another file. Here is my sofar code.
// $data is array with the urls $count_array = count($data); $maxlinksinsitemap = 50000; $numbersofsitemap = ceil($count_array / $maxlinksinsitemap); for($i = 1; $i <= $numbersofsitemap; $i++) { $cfile = "sitemap_" .$i . ".xml"; $createfile = fopen($cfile, 'w'); $creat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $creat .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n"; $creat .= "xmlns:image=\"http://www.sitemaps.org/schemas/sitemap-image/1.1\"\n"; $creat .= "xmlns:video=\"http://www.sitemaps.org/schemas/sitemap-video/1.1\">\n"; $creat .= "<url>\n"; $creat .= "<loc>http://www.urltosite.com</loc>\n"; $creat .= "<priority>1.00</priority>\n"; $creat .= "</url>\n"; $creat .= "</urlset>"; fwrite($createfile, $creat); fclose($createfile); }
I need a dynamic solution,
Thanks for the help.
source share