Clickable link PHP


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



Copy this code and paste it in your HTML
  1. protected function clickable_link($url,$chr_limit = 35,$add = '...')
  2. {
  3. return preg_replace("!(http:/{2}[\w\.]{2,}[/\w\-\.\?\&\=\#]*)!e", "'<a href=\"\\1\" title=\"\\1\" target=\"_blank\">'.(strlen('\\1')>=$chr_limit ? substr('\\1',0,$chr_limit).'$add':'\\1').'</a>'", $url);
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.