php 规划HTML链接的URL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 规划HTML链接的URL相关的知识,希望对你有一定的参考价值。

function linkable($text = ''){
    $text = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $text));
    $data = '';
    foreach( explode(' ', $text) as $str){
        if (preg_match('#^http?#i', trim($str)) || preg_match('#^www.?#i', trim($str))) {
            $data .= '<a href="'.$str.'">'.$str.'</a> ';
        } else {
            $data .= $str .' ';
        }
    }
    return trim($data);
	}

以上是关于php 规划HTML链接的URL的主要内容,如果未能解决你的问题,请参考以下文章

HTML链接PHP解析器的URL

发送带有 php 链接的短信

微信(url.cn)短网址生成api接口以及php,python的调用方法

将数据库中的值作为 PHP/HTML 表中的链接回显 [关闭]

与正则表达式链接的 PHP URL

php 获取 链接上的 参数