PHP if string contains URL isolate it

后端 未结 4 1236
借酒劲吻你
借酒劲吻你 2020-12-21 22:43

In PHP, I need to be able to figure out if a string contains a URL. If there is a URL, I need to isolate it as another separate string.

For example: \"SESAC showin t

4条回答
  •  独厮守ぢ
    2020-12-21 23:34

    this doesn't account for dashes -. needed to add -

    preg_match('/[a-zA-Z]+:\/\/[0-9a-zA-Z;.\/\-?:@=_#&%~,+$]+/', $_POST['string'], $matches);
    

提交回复
热议问题