string ltrim function - removes whitespace(s) or space character(s) from the beginning of a string

string ltrim function - removes whitespace(s) or space character(s) from the beginning of a string

string-ltrim-function-example-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 ltrim function - removes whitespace(s) or space character(s) from the beginning of a 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 ltrim function - removes whitespace(s) or space character(s) from the beginning of a string">
  <meta name="keywords" content="php, example, code, array, function, ltrim, string">
  <meta name="description" content="string ltrim function - removes whitespace(s) or space character(s) from the beginning of a string">
  <style>
   h2, h4{background:#ccc; color:#000079;}
   h2{ padding:3px; margin:3px; font-size:20px;}
   h4{ padding:2px; margin:2px; font-size:17px;}
   p{padding:2px; margin:2px; color:#336600;}
   body{ background:#FFFFFa;}
  </style>
 </head>
 <body>
  <h2>string ltrim function - removes whitespace(s) or space character(s) from the beginning of a string</h2>
  <pre>
   <?php
    /*
     ----------------------------------------------------
     let us make a string holding space at the beginning
     ----------------------------------------------------
    */
    $whitespaceedString = "  this is a whitespaceed string.";
    echo "<h4>Output of whitespaceedString</h4>";
    print "<p>$"."whitespaceedString = {$whitespaceedString}</p>";
    print "<p>string length : ".strlen($whitespaceedString)."</p>";
    /*
     ------------------------------------------------------------------------------------------
     we want to remove the whitespace from the beginning of the string by using ltrim function
     ------------------------------------------------------------------------------------------
    */
    $whitespaceRemovedString = ltrim($whitespaceedString);
    echo "<h4>Output of whitespaceRemovedString by using string ltrim function</h4>";
    print "<p>$"."whitespaceRemovedString = {$whitespaceRemovedString}</p>";
    print "<p>string length : ".strlen($whitespaceRemovedString)."</p>";
   ?>
  </pre>
 </body>
</html>

string ltrim function - removes whitespace(s) or space character(s) from the beginning of a string - output in the browser

No comments:

Post a Comment

leave your comments here..