$string = '[mybbcode] http://www.site1.com/ http://www.site2.com/ http://www.site3.com/ [/mybbcode] $string = explode("\n", $string); foreach($string as $link){ echo '<a href="'. $link . '">'.$link.'</a>'; }