How do I remove trailing whitespace?
The function of choice here would be chop, like so:
<?php
$contents = " I'm spaced out ";
echo "<$contents>\n";
echo "<" . chop($contents) . ">";
< I'm spaced out >
< I'm spaced out>
?>
Note that the trailing space has all been removed from the second line, and also that the leading space is still there... if you want to get rid of that, it's a job for trim!
Comment on this Question and Answer >>>
ASK A QUESTION
More strings PHP Questions
How do I escape a string with slashes?How do I count how many times each character occurs in a string?
How do I check if a string contains HTML?
What is the difference between ' and "?
How do you hash the password in this php script: define(sb db user name, admin store); define(sb db password, mypassword);
