3v4l.org

run code in 500+ PHP versions simultaneously
<?php $xml = <<<EOT <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>https://subdomain.example.com</loc> <priority>1.0</priority> <changefreq>always</changefreq> </url> <url> <loc>https://subdomain.example.com/s/queen-katwe-2016-720p-hd-480p-hd/</loc> <priority>1.0</priority> <changefreq>always</changefreq> </url><url> <loc>https://subdomain.example.com/s/justice-league-dark-2017-720p-hd-480p-hd/</loc> <priority>1.0</priority> <changefreq>always</changefreq> </url><url> <loc>https://subdomain.example.com/s/edge-seventeen-2016-720p-hd-480p-hd/</loc> <priority>1.0</priority> <changefreq>always</changefreq> </url></urlset> EOT; $dom = new DOMDocument; $dom->loadXML($xml); foreach($dom->getElementsByTagName('loc') as $node) { if ((XML_ELEMENT_NODE === $node->nodeType) && ('loc' === $node->nodeName)){ $node->nodeValue = mb_strimwidth($node->nodeValue, 0, 15); } } echo $dom->saveHTML();

preferences:
47.56 ms | 1379 KiB | 5 Q