Skip to the content
Documentation

nl2br

No ratings yet

Summary

Returns the input string with all newlines converted to HTML breaks.

Usage

input|nl2br()

Returns

A string with HTML breaks.

Description

This operator takes a string as input. It replaces newline characters/sequences with HTML break tags and returns a modified version of the input.

Examples

Example 1

{'The lazy
cat
jumps over
the quick rat.'|nl2br()}

The following output will be produced:

The lazy<br />cat<br />jumps over<br />the quick rat.

Contributors

Comments (2 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. example

    Adrien ·

    break() is an alias for nl2br()? Anyway, the example should deal with the current operator nl2br().

    1. Re: example

      Julia Shymova ·

      break() is completely equal to nl2br() operator.
      The example is now fixed. Thanks for pointing this out.

Comments

Add a comment

Comments are read by a moderator before they appear.