Replace URLs in text with HTML links

后端 未结 17 1983
栀梦
栀梦 2020-11-22 11:27

Here is a design though: For example is I put a link such as

http://example.com

in textarea. How do I get PHP t

17条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 12:11

    This worked for me (turned one of the answers into a PHP function)

    function make_urls_from_text ($text){
       return preg_replace('/(http[s]{0,1}\:\/\/\S{4,})\s{0,}/ims', '$1 ', $text);
    }
    

提交回复
热议问题