rtrim(): rtrim is great for
deleting that unwanted space at then end of strings. The
perfect example for using this function is when receiving
data from an online form and, at the end of a data field,
some one leaves an extra white space. This white space means
nothing and you want to delete it. rtrim() to the rescue.
Example:
$password = "123 ";
$password = rtrim($password);
// $password = "123"
?>
Other Examples:
You can also trim down a string by matching words or letters
and the end of a string.
Example:
// Example 1: Character-by-character comparison match.
echo rtrim('
This is a test test code', 'test code');
// returns 'This is a'
// Example 2: matches the last whole word with half the
letters
echo rtrim('
This is a test', 'est');
// returns 'This is a'
?>
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.