trim() in php

Tuesday, November 11, 2008 10:53
Posted in category PHP

If you use a form on your site then you’ll know that user input can often have white space before or after the text as the person filling in the form field sometimes accidentally adds spaces. This handy function will remove the whitespace from the beginning or end of the string.



< ?php

echo trim($_REQUEST['name']);

?> 

after removing the white spaces

out put :hai

< ?php
$value=" Hello world ";
function trim_value($value) {
echo $value = trim($value);
}
?> 

out put:

Hello world

Bookmark and Share

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

You can leave a response, or trackback from your own site.

Leave a Reply