fork download
  1. <?php
  2. $text = 'сайт http://a...content-available-to-author-only...2.ru/usr/handler/%D0%BA%D0 далее';
  3. function cb_function($matches)
  4. {
  5. $href = $matches[0];
  6. $parse = parse_url($href);
  7. $domen = $parse['host'];
  8. return "<a rel=\"nofollow\" target=\"_blank\" href=\"$href\">Ссылка: $domen</a>";
  9. }
  10.  
  11. $text = preg_replace_callback("/http(s)?:\/\/[^\s]+/", "cb_function", $text);
  12. echo $text;
  13. ?>
Success #stdin #stdout 0.01s 13112KB
stdin
Standard input is empty
stdout
сайт <a rel="nofollow" target="_blank" href="http://a...content-available-to-author-only...2.ru/usr/handler/%D0%BA%D0">Ссылка: apokalipsis-2012.ru</a> далее