PHP replacing URL to a href [duplicate]
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
精彩评论