Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8425 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97039 invoked by uid 1010); 7 Mar 2004 23:35:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96981 invoked from network); 7 Mar 2004 23:35:22 -0000 Received: from unknown (HELO mail-in-04.arcor-online.net) (151.189.21.44) by pb1.pair.com with SMTP; 7 Mar 2004 23:35:22 -0000 Received: from tolpan.homenet (dsl-082-083-132-104.arcor-ip.net [82.83.132.104]) by mail-in-04.arcor-online.net (Postfix) with ESMTP id 947BE9F2BCF for ; Mon, 8 Mar 2004 00:35:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by tolpan.homenet (Postfix) with ESMTP id 96A2B87E6 for ; Mon, 8 Mar 2004 00:35:20 +0100 (CET) Received: by tolpan.homenet (Postfix, from userid 65534) id D558F87E1; Mon, 8 Mar 2004 00:35:13 +0100 (CET) Received: from flint.homenet (flint.homenet [192.168.1.62]) by tolpan.homenet (Postfix) with ESMTP id 5C6A787C2 for ; Mon, 8 Mar 2004 00:35:02 +0100 (CET) To: internals@lists.php.net Date: Mon, 8 Mar 2004 00:35:42 +0100 User-Agent: KMail/1.5.4 References: <404B64CC.5070108@sympatico.ca> <20040307205831.GA16606@prp0.prp.physik.tu-darmstadt.de> In-Reply-To: <20040307205831.GA16606@prp0.prp.physik.tu-darmstadt.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200403080035.43832.cyberian@arcor.de> X-Spam-Status: No, hits=-1.4 required=5.0 tests=EMAIL_ATTRIBUTION,HTML_00_10,HTML_MESSAGE,IN_REP_TO, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_KMAIL version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) X-Virus-Scanned: by AMaViS 0.3.12pre8 Subject: Re: [PHP-DEV] Function proposal: nl2p From: cyberian@arcor.de (Kai =?iso-8859-1?q?Schr=F6der?=) On Sunday 07 March 2004 21:58, Stefan Walk wrote: > On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote: > > I wrote this very simple function (modification from nl2br actually) to > > convert newlines to well formatted HTML paragraphs instead of line > > breaks, allowing better formatting of a dynamic output. It's not the > > most perfect piece of code ever written, but it works and it can be > > quite useful. > > The
tag does not have as much possibilities as the

tag when > > it comes to CSS, which gave me the idea to write this function. > function nl2p($str) { > return '

'.preg_replace('/\r\n|\n|\r/', '

$0

', $str).'

'; > } > I think that function is not neccessary... nl2br is already redundant. > They are one-liners in php itself... so no need to write functions for > them. More ideas for intresting functions specialy for websites: - nl2span($text, $array_of_arguments_for_span) - nl2div($text, $array_of_arguments_for_div) - obfuscate_mailaddr($mail_addr). Intresting for users that need such functions on several places in code and in this case better as regexp in PHP itself. Why not take this ideas and put together into ext/html(format)? Regards, Kai