Replace URLs in text with HTML links

后端 未结 17 1777
栀梦
栀梦 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 11:54

    You guyz are talking way to advance and complex stuff which is good for some situation, but mostly we need a simple careless solution. How about simply this?

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

    Just try it and let me know what crazy url it doesnt satisfy.

提交回复
热议问题