Navigation :

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




Site Sponsors :

Bookmark :

Links :

wwwstores
low cost magazines
software directory

Downloads :

Misc :

Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!




Using trim to get rid of whitespace

This shows how to use the trim function to remove white spaces from either side of a string

<?php
//trimming white space from a string
//our two strings
$string1 = " spaces before";
$string2 = " spaces before and after ";
//remove the whitespace
$trimmed_string1 = trim($string1);
$trimmed_string2 = trim($string2);
//display the text
echo $trimmed_string1;
echo "<br>";
echo $trimmed_string2;
?>