PHP trim removal null character definition and syntax introduction _php tutorial

Source: Internet
Author: User
Definition and Usage
The trim () function removes white-space characters and other predefined characters from both ends of the string.

Grammar
Trim (string,charlist) parameter description

string is required. Specifies the string to check.

Charlist is optional. Specifies the string to convert. If this argument is omitted, all of the following characters are removed:
Copy CodeThe code is as follows:
"+"-NULL
"\ T"-tab
"\ n"-New line
"\x0b"-Vertical list character
"\ r"-Enter
""-Plain white space character

Example 1
Copy CodeThe code is as follows:
$STR = "Use function trim to remove whitespace characters at both ends of the string";
$str 1 = Trim ($STR); echo "Before processing". strlen ($STR). " Characters ";
echo "
";
echo "
";
echo "has been processed with the trim function". strlen ($str 1). " Characters ";
?>

Output:

39 characters before processing 34 characters after using the PHP function trim ()

Example 2
Copy CodeThe code is as follows:
$str = "# #使用函数trim去掉字符串两端特定字符 # # #;
$str 1 = Trim ($str, "#"); When you pass in the second parameter for function trim, Trim deletes the # character at both ends of the string $str
echo $str. "
";
echo $str 1;
?>

Output:
# #使用PHP函数trim () remove specific characters at both ends of a string # # # # Use function trim to remove specific characters at both ends

http://www.bkjia.com/PHPjc/322032.html www.bkjia.com true http://www.bkjia.com/PHPjc/322032.html techarticle The define and use trim () function removes whitespace characters and other predefined characters from both ends of a string. The syntax trim (string,charlist) parameter describes a string that is required. Specifies the string to check. ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.