string nl2br function - it puts HTML line breaks before all newlines in the given string

string nl2br function - it puts HTML line breaks before all newlines in the given string

string-nl2br-function-in-php.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>string nl2br function - it puts HTML line breaks before all newlines in the given string</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="Author" content="Md Iqbal Hosan">
  <meta name="title" content="string nl2br function - it calculates how may characters to be changed to make two strings similar">
  <meta name="keywords" content="php, example, code, array, function, nl2br , string">
  <meta name="description" content="string nl2br function - it calculates how may characters to be changed to make two strings similar">
  <style>
   h2, h4{background:#ddd; color:#000065;}
   h2{ padding:3px; margin:3px; font-size:23px;}
   h4{ padding:2px; margin:2px; font-size:19px;}
   p{padding:2px; margin:2px; color:#0099cc;}
   body{ background:#FFFFFd;}
   span{ color:orange;}
  </style>
 </head>
 <body>
  <h2>string nl2br function - it calculates how may characters to be changed to make two strings similar</h2>
  <pre>
   <?php
    /*
     --------------------------------------------------------
     let me tell you my boss's name and his favourite color.
     --------------------------------------------------------
    */
    $myString = "my boss's name is cfsuman.\nAnd his favourite color is <span>orange</span>.";
    echo "<h4>Output of myString</h4>";
    print "<p>$"."myString = {$myString}</p>";
    /*
     ----------------------------------------------------------------------------
     now we want to replace the \n with html <br> by using string nl2br function
     ----------------------------------------------------------------------------
    */
    $replacedString = nl2br($myString);
    echo "<h4>Output of replacedString by using string nl2br function</h4>";
    print "<p>$"."replacedString = {$replacedString}</p>";
   ?>
  </pre>
 </body>
</html>

string nl2br function - it puts HTML line breaks before all newlines in the given string - output in the browser

No comments:

Post a Comment

leave your comments here..