3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "~(?:f|ht)tps?://[a-z\d.-]+\.[a-z]{2,3}\S*~i"; $text = 'http://google.com and http://facebook.com?12345678901234567890123456789012345678901234567890 are big companies. A good example for shopping site is http://amazon.com'; echo preg_replace_callback($pattern, function($m) { return "<a href=\"{$m[0]}\" rel=\"nofollow\"><b>" . (strlen($m[0]) > 50 ? substr($m[0], 0, 50) . "..." : $m[0]) . "</b></a>"; }, $text);

preferences:
163.98 ms | 405 KiB | 5 Q