Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here is link: http://google.com
- And http://example.com inside.
- And another one at the very end: http://test.net
- Here is link: <a href="http://google.com">http://google.com</a>
- And <a href="http://example.com">http://example.com</a> inside.
- And another one at the very end: <a href="http://test.net">http://test.net</a>
- function make_links_clickable($text){
- // ???
- }
- $text = 'Here is link: http://google.com
- And http://example.com inside.
- And another one at the very end: http://test.net';
- echo make_links_clickable($text);
- function make_links_clickable($text){
- return preg_replace('!(((f|ht)tp://)[-a-zA-Zа-яА-Я()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text);
- }
- function make_links_clickable($text)
- {
- return preg_replace ('/http://[^s]+/i', "<a href="${0}">${0}</a>", $text);
- }
- $result = function make_links_clickable($text);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement