3v4l.org

run code in 500+ PHP versions simultaneously
<?php $xml = <<<EOT <loc>https://subdomain.example.com</loc> <loc>https://subdomain.example.com/s/queen-katwe-2016-720p-hd-480p-hd/</loc> <loc>https://subdomain.example.com/s/justice-league-dark-2017-720p-hd-480p-hd/</loc> <loc>https://subdomain.example.com/s/edge-seventeen-2016-720p-hd-480p-hd/</loc> EOT; var_dump( preg_replace_callback( '/<loc>(?<value>[^<]+)<\/loc>/', static function($matches) { return sprintf('<loc>%1$s</loc>', mb_strimwidth($matches['value'], 0, 15)); }, $xml ) );
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
string(107) "<loc>https://subdoma</loc> <loc>https://subdoma</loc> <loc>https://subdoma</loc> <loc>https://subdoma</loc>"

preferences:
93.8 ms | 1272 KiB | 4 Q