I’d like to setup a function in Codeigniter that would turn URLs into active links. I found the function below here–it’s for PHP generally, but need something similar for Codeigniter. Would like to use it throughout my site for user posts and comments.
$text = preg_replace('/(?<!http:\/\/)(www.[-a-zA-Z0-9@:%_\+.~#?&\/=]+)/i', '<a href="http://\1">\1</a>', $text);
I ended up using auto_link() which is a function built into codeigniter. So if someone posts a message and you want to linkify any urls, simply use:
I found it buried in the codeigniter documentation.