英[trɪm] 美[trɪm]

vt. Decorate; trim; organize

adj. Neat, tidy; slender; slender

n .Trim; tidy; healthy state; attire

vi.cut

Third person singular: trims Present participle: trimming Past tense: trimmed Past participle: trimmed Comparative: trimmer Superlative: trimmest

php trim() function syntax

How to use the trim() function?

php trim() function is used to remove spaces or other predefined characters at both ends of a string. The syntax is trim(string, charlist) and returns the string processed by charlist

Function:Remove spaces or other predefined characters at both ends of the string

Syntax: trim(string, charlist);

Parameters:

Parameter Description
string Specifies to process The string
charlist is optional and specifies which characters are to be removed from the string. If it is empty, all the following characters are removed: "\0" -- NULL, "\t" -- tab character, "\n" -- line feed, "\x0B" -- vertical tab character, "\r" -- carriage return, " " -- space

Description: Return the string processed by charlist

php trim() function example

<?php
$i = "   hello world   ";
echo "没有经过trim处理".$i;
echo "<br>";
$j = trim($i);
echo "经过trim处理".$j;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

没有经过trim处理 hello world 
经过trim处理hello world