TPLix

No results for ""

Nl2br

2 min read Jun 2, 2026
--- title: nl2br autoseo: enabled: true theme: learn2 child_type: default admin: children_display_order: collection visible: true ---

nl2br — Inserts HTML line breaks before all newlines in a string

<?php
$tplix->assign('articleTitle',
                "Sun or rain expected\ntoday, dark tonight"
                );
Basic Usage:
{$article|nl2br}

Returns string with
or
inserted before all newlines (\r\n, \n\r, \n and \r).

Parameters:
Parameter Type Required Description
1 bool No true, Whether to use XHTML compatible line breaks or not.

Where the template is:


{$articleTitle|nl2br} # renders: Sun or rain expected<br />today, dark tonight
{$articleTitle|nl2br:true} # renders: Sun or rain expected<br />today, dark tonight

Leave a Comment

Not published. Used to notify you on approval.

Comments are moderated before appearing.