Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

trim - remove white spaces from both ends of a string

  • trim
  • ltrim
  • rtrim
<?php
   $str = "   some text  ";
   echo "'$str'";
   echo "<br>";
   echo trim($str);
?>
   

trim

White space characters are \n, \r, \t and space itself. ltrim is left trim, rtrim is right trim.