Powered by InterCreatives | Site Map
Search:
NewSourceMedia Popular Tutorials: PHP Javascripts Web Hosting
SoftwareTutorials
CATEGORIES
Job Listings
 
Home / PHP / Content Management

PHP strip remove white space from end of string

Published by: Alex


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'
?>


Next PHP Page:
1  2  3  4  5  6  7  8  9  10  [11]  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32 





Hosting by iPowerWeb.com - 50 Gb for $7.95