unwrap link in codeigniter auto_link


/ Published in: PHP
Save to your folder(s)

solving unwrapped link in auto_link() function


Copy this code and paste it in your HTML
  1. //1. comment these lines in text_helper.php
  2. if (preg_match("!\[url.+\]|://|wwww.!", $line))
  3. {
  4. break;
  5. }
  6.  
  7. //2. find this script in url_helper.php,
  8. $str = str_replace($matches['0'][$i],
  9. $matches['1'][$i].'<a href="http'.
  10. $matches['4'][$i].'://'.
  11. $matches['5'][$i].
  12. $matches['6'][$i].'"'.$pop.'>http'.
  13. $matches['4'][$i].'://'.
  14. $matches['5'][$i].
  15. $matches['6'][$i].'</a>'.
  16. $period, $str);
  17.  
  18. //and replace with this,
  19. $str = str_replace($matches['0'][$i],
  20. $matches['1'][$i].'<a {unwrap} href="http'.
  21. $matches['4'][$i].'://'.
  22. $matches['5'][$i].
  23. $matches['6'][$i].'" {/unwrap} '.$pop.'>http'.
  24. $matches['4'][$i].'://'.
  25. $matches['5'][$i].
  26. $matches['6'][$i].'</a>'.
  27. $period, $str);
  28.  
  29. //3. then use with word_wrap() from text_helper.php
  30.  
  31. echo word_wrap(auto_link($string));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.