trim() in php
Tuesday, November 11, 2008 10:53If 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
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

