Replace URLs in text with HTML links

后端 未结 17 1998
栀梦
栀梦 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:09

    this should get you email addresses:

    $string = "bah bah steve@gmail.com foo";
    $match = preg_match('/[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+/', $string, $array);
    print_r($array);
    
    // outputs:
    Array
    (
        [0] => steve@gmail.com
    )
    

提交回复
热议问题