开发者

PHP replacing URL to a href [duplicate]

开发者 https://www.devze.com 2023-03-27 02:03 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: PHP URL to Link with Regex
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

PHP URL to Link with Regex

how to convert some urls in string to <a href="here url">here url</a>?

开发者_如何转开发

I'm thinking about preg_replace but what regex to use?

Thanx!


It's not advised to use regex with html code, as HTML is a context free language, and regular expressions are most advised to use with regular languages. Instead look into DOM libraries, as an easy way to find and replace attributes of html tags: http://php.net/manual/en/book.dom.php

0

精彩评论

暂无评论...
验证码 换一张
取 消