string chop function - removes whitespace(s) or space character(s) from the end of a string
string-chop-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 chop 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 chop function - removes whitespace(s) or space character(s) from the end of a string">
<meta name="keywords" content="php, example, code, array, function, chop, string">
<meta name="description" content="string chop function - removes whitespace(s) or space character(s) from the end of a string">
<style>
h2, h4{background:#ccc; color:#000078;}
h2{ padding:3px; margin:3px; font-size:21px;}
h4{ padding:2px; margin:2px; font-size:17px;}
p{padding:2px; margin:2px; color:#3333Fe;}
body{ background:#FFFFFb;}
</style>
</head>
<body>
<h2>string chop 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
----------------------------------------------------
*/
$spacedString = "this is a whitespaceed string.\t\t";
echo "<h4>Output of whitespaceed String</h4>";
print "<p>$"."spacedString = {$spacedString}</p>";
print "<p>string length : ".strlen($spacedString)."</p>";
/*
------------------------------------------------------------------------------------------
we want to remove the whitespace at the end of the string by using chop function
------------------------------------------------------------------------------------------
*/
$spaceRemovedString = chop($spacedString);
echo "<h4>Output of spaceRemovedString by using string chop function</h4>";
print "<p>$"."spaceRemovedString = {$spaceRemovedString}</p>";
print "<p>string length : ".strlen($spaceRemovedString)."</p>";
?>
</pre>
</body>
</html>

No comments:
Post a Comment
leave your comments here..