- preg_replace_callback: documentation ( source)
<?php
$bt ="http://www.xdytt.com/wp-content/uploads/2014/07/0e1f7d6029a030b3.torrenthttp://www.xdytt.com/wp-content/uploads/2014/07/8af4e5816cc01962.torrenthttp://www.xdytt.com/wp-content/uploads/2014/07/0e1f7d6029a030b3.torrenthttp://www.xdytt.com/wp-content/uploads/2014/07/8af4e5816cc01962.torrenthttp://www.xdytt.com/wp-content/uploads/2014/07/0e1f7d6029a030b3.torrenthttp://www.xdytt.com/wp-content/uploads/2014/07/8af4e5816cc01962.torrent";
$text = "";
$preg = "/(http.*?\/[0-9]{2}\/(.*?)\.torrent)/i";
preg_replace_callback($preg, function($m) use(&$text) {
$text .= "<a href=\"{$m[1]}\">{$m[2]}</a>\r\n";
}, $bt);
echo $text;