note 125153 added to function.nl2br

From: Date: Mon, 29 Jun 2020 20:03:00 +0000
Subject: note 125153 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-214816@lists.php.net to get a copy of this message
This is a simple trick to transform newlines to paragraph a $string : <?php $string_with_paragraphs = "<p>".implode("</p><p>", explode("\n", $string))."</p>"; ?> By exploding on new lines & adding end & begin for p, it's easy to concat with <p>. You can bring it to a function : <?php function nl2p($string) { return $string_with_paragraphs = "<p>".implode("</p><p>", explode("\n", $string))."</p>"; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.166.36 (proxied: 86.212.17.46) ---- Manual Page -- http://php.net/manual/en/function.nl2br.php Edit -- https://master.php.net/note/edit/125153 Del: integrated -- https://master.php.net/note/delete/125153/integrated Del: useless -- https://master.php.net/note/delete/125153/useless Del: bad code -- https://master.php.net/note/delete/125153/bad+code Del: spam -- https://master.php.net/note/delete/125153/spam Del: non-english -- https://master.php.net/note/delete/125153/non-english Del: in docs -- https://master.php.net/note/delete/125153/in+docs Del: other reasons-- https://master.php.net/note/delete/125153 Reject -- https://master.php.net/note/reject/125153 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#214816) next »