- preg_replace_callback: documentation ( source)
- base64_encode: documentation ( source)
<?php
$html = 'ahsgdjagshjdgasjdgajgsd gjagdjhagsjhgda sgdhjagsjdgajhgdjad<a href="http://short.awsubs.co/be9Vk">Solidfiles</a> jashd sha7st7atsdgasgda sgahsfd ahgsfafd<a href=https://link.safelinkconverter.com/review.php?id=aHR0cDovL2JfdC5seS8ySDdMajh3&c=1&user=61942 rel=nofollow>Zippyshare</a>';
echo preg_replace_callback('~href=[\'"]?([^\s\'"]+)[\'"]?(.*?)>(.*?)</a>~', function($m) {
//var_export($m);
return "<a href=\"" . base64_encode($m[1]) . "\"{$m[2]}>{$m[3]}</a>";
}, $html);