note 32177 deleted from function.preg-replace-callback by sniper

From: Date: Tue, 30 Sep 2003 12:26:04 +0000
Subject: note 32177 deleted from function.preg-replace-callback by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57451@lists.php.net to get a copy of this message
Note Submitter: dfx@dfx.at ---- here's how you can turn plain text into html, turning plain urls into hyperlinks: function urlparse($m) { $t = $m[0]; if (preg_match(',^\w+://,', $t)) return "<a href=\"$t\">$t</a>"; return "<a href=\"http://$t\">$t</a>"; } function parseplaintext($d) { $pd = str_replace("\n", "<br />", htmlspecialchars($d)); $pd = preg_replace_callback( '°(\w+://([^\s/:@]+(:[^\s/:@]++)?@)?|\bwww\.)' . '[\w.]+(:\d+)?(/([-\w?&%+#;|@]*[\w-])?)?°is', "urlparse", $pd); return $pd; }

« previous php.notes (#57451) next »