By using trim() in build php function we can remove the white spaces from the string. trim() function removes the white spaces from the starting of the string as well as ending of the string. It will not remove the white space from middle of the string.

Example:
<?php
$str = '    Php is not supporting multilevel inheritance. ';
echo strlen($str); // Outputs: 50
 
$trim_str = trim($str);
echo strlen($trim_str); // Outputs: 45
?>
Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply