Php parse links/emails

前端 未结 4 1108
时光取名叫无心
时光取名叫无心 2020-12-06 08:11

I am wondering if there is a simple snippet which converts links of any kind:

http://www.cnn.com to http://www.cnn.com&l         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 08:24

    Here's the email snippet:

    $email = "abc@def.com";
    
    $pos = strrpos($email, "@");
    if (!$pos === false) {
        // This is an email address!
        $email .= "mailto:" . $email;
    }
    

    What exactly are you looking to do with the links? strip the www or http? or add http://www to any link if required?

提交回复
热议问题