Hi siddu,
White spaces can be removed from many php functions as below.
trim() - Remove white space characters from the beginning and the end of a string.
ltrim() - Remove white space characters from the beginning of a string.
rtrim() - Remove white space characters from the end of a string.
chop() - Same as rtrim().
Here is a PHP script example of trimming strings:
<?php
$text = "t t Hello world!t t ";
$leftTrimmed = ltrim($text);
$rightTrimmed = rtrim($text);
$bothTrimmed = trim($text);
print("leftTrimmed = ($leftTrimmed)n");
print("rightTrimmed = ($rightTrimmed)n");
print("bothTrimmed = ($bothTrimmed)n");
?>
This script will print:
leftTrimmed = (Hello world! )
rightTrimmed = ( Hello world!)
bothTrimmed = (Hello world!)
Oct 27, 2009