trim()Removes leading/trailing whitespace.Syntaxtrim($text)DescriptionCleans up spaces/newlines at the beginning and end of the text.ExampleLoading editor…▶ Try it yourselfExpected outputspaceWhen to use?Cleaning form input.Related commandsstr_replace()← strtoupper() / strtolower()str_replace() →