0
所以我现在有这...如何找到,使链路和缩短文本块URL文本与PHP
<?php
$textblockwithformatedlinkstoecho = preg_replace('!(((f|ht)tp(s)?://)[-a-zA-
Zа-яА-Я()[email protected]:%_+.~#?&;//=]+)!i', '<a href="$1" target="popup">$1</a>',
$origtextwithlinks);
echo $textblockwithformatedlinkstoecho;
?>
不过,我想也缩短可点击链接到长约15个字符...
示例输入文本
I recommend you visit http://www.example.com/folder1/folder2/page3.html?
longtext=ugsdfhsglshghsdghlsg8ysd87t8sdts8dtsdtygs9ysd908yfsd0fyu for more
information.
需要的输出文本
I recommend you visit example.com/fol... for more information.
您可以使用[preg_replace_callback()](http://php.net/manual/en/function.preg-replace-callback.php)在替换之前对其进行操作。 –