I want:
Here is link: http://google.com And http://example.com inside. And another one at the very end: http://test.net
to become:
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>
Seems like a trivial task, but I cannot find a PHP function that works. Do you have any ideas?
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);
Right-click anywhere on the link and, on the shortcut menu, click Edit Hyperlink. In the Edit Hyperlink dialog, select the text in the Text to display box. Type the text you want to use for the link, and then click OK.
We simply add the onlcick event and add a location to it. Then, additionally and optionally, we add a cursor: pointer to indicate to the user the div is clickable. This will make the whole div clickable.
Link blocks are similar to Div blocks in that they can be used for structure and layout, but the area inside of the Link block becomes a link. Link blocks can turn any element, like an image, or any layout, like a banner, into a link.
Use this (works with ftp, http, ftps and https schemes):
function make_links_clickable($text){ return preg_replace('!(((f|ht)tp(s)?://)[-a-zA-Zа-яА-Я()0-9@:%_+.~#?&;//=]+)!i', '<a href="$1">$1</a>', $text); }
Try something like this:
function make_links_clickable($text) { return preg_replace ('/http:\/\/[^\s]+/i', "<a href=\"${0}\">${0}</a>", $text); } $result = make_links_clickable($text);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With