Welcome Guest, Not a member yet? Register   Sign In
Does anyone here know how to extract url on textarea using CI?
#1

[eluser]coderedmax[/eluser]
Like title said anyone here knows or have a function how to detect url on text area and convert it to anchor tag?

example :

user input this on textarea
Code:
I really love codeigniter visit http://codeigniter.com

then when need to input on database must be converted to
Code:
I really love codeigniter visit <a href="http://codeigniter.com" rel="nofollow">http://codeigniter.com</a>

like that! Anyone knows? thank you.
#2

[eluser]bubbafoley[/eluser]
use auto_link() in the url helper

Code:
echo auto_link('I really love codeigniter visit http://codeigniter.com');

http://ellislab.com/codeigniter/user-gui...elper.html
#3

[eluser]coderedmax[/eluser]
@bubbafoley

thanks! I didn't know CI have that features. :vampire:

anyway I got also alternative solution:
Code:
$content = $this->input->post('discussion_content', TRUE);
$find_url = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '<a href="$1" target="_blank">$1</a>', $content);

almost same but yours is easier. =) thanks again!




Theme © iAndrew 2016 - Forum software by © MyBB