PHP 8.5.0 Alpha 1 available for testing

Voting

: eight plus zero?
(Example: nine)

The Note You're Voting On

Oyedele Hammed Horlah - itz dot harmid at gmail dot com
7 years ago
this is a simple function to replace all newlines to <br> tags.

\r\n - windows line break
\n - linux line break
\r - mac line break

<?php
function nl_to_br($str) {
return
str_replace(array("\r\n","\n","\r"), "<br/>", $str);
}
echo
nl_to_br('Hello world\n I am Oyedele Hammed Horlah'); // => Hello World <br> I am Oyedele Hammed Horlah
?>

Enjoy

<< Back to user notes page

To Top