<?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 ) );
You have javascript disabled. You will not be able to edit any code.