string rtrim function - removes whitespace(s) or space character(s) from the end of a string

string rtrim function - removes whitespace(s) or space character(s) from the end of a string

string-rtrim-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 rtrim function - removes whitespace(s) or space character(s) from the end 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 rtrim function - removes whitespace(s) or space character(s) from the end of a string">
  <meta name="keywords" content="php, example, code, array, function, rtrim, string">
  <meta name="description" content="string rtrim function - removes whitespace(s) or space character(s) from the end of a string">
  <style>
   h2, h4{background:#bbb; color:#000082;}
   h2{ padding:3px; margin:3px; font-size:22px;}
   h4{ padding:2px; margin:2px; font-size:18px;}
   p{padding:2px; margin:2px; color:#3333FF;}
   body{ background:#FFFFFc;}
  </style>
 </head>
 <body>
  <h2>string rtrim function - removes whitespace(s) or space character(s) from the end of a string</h2>
  <pre>
   <?php
    /*
     ----------------------------------------------------
     let us make a string holding whitespaces at the end
     ----------------------------------------------------
    */
    $whitespacedString = "this is a whitespaceed string.\t\t";
    echo "<h4>Output of whitespaceed String</h4>";
    print "<p>$"."whitespacedString = {$whitespacedString}</p>";
    print "<p>string length : ".strlen($whitespacedString)."</p>";
    /*
     ------------------------------------------------------------------------------------------
     we want to remove the whitespace at the end of the string by using rtrim function
     ------------------------------------------------------------------------------------------
    */
    $spaceRemovedString = rtrim($whitespacedString);
    echo "<h4>Output of spaceRemovedString by using string rtrim function</h4>";
    print "<p>$"."spaceRemovedString = {$spaceRemovedString}</p>";
    print "<p>string length : ".strlen($spaceRemovedString)."</p>";
   ?>
  </pre>
 </body>
</html>

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

No comments:

Post a Comment

leave your comments here..