note 63199 deleted from function.preg-replace by colder

From: Date: Mon, 18 Jun 2007 19:59:39 +0000
Subject: note 63199 deleted from function.preg-replace by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127689@lists.php.net to get a copy of this message
Note Submitter: Ciprian Amariei ---- Here is a function that replaces the links (http(s)://, ftp://) with respective html anchor, and also makes all anchors open in a new window. function make_links_blank( $text ) { return preg_replace( array( "/[^\"'=]((http|ftp|https):\/\/[^\s\"']+)/i", "/<a([^>]*)target=\"?[^\"']+\"?/i", "/<a([^>]+)>/i" ), array( "<a href=\"\\1\">\\1</a>", "<a\\1", "<a\\1 target=\"_blank\" >" ), $text ); }

« previous php.notes (#127689) next »