PHP trim()函数详解

2021-03-26 01:24

阅读:481

标签:制表符   0x0d   strip   五个   feed   binary   rri   垂直   The   

定义

trim - 去除字符串里的空白符及其他指定字符

Strip whitespace (or other characters) from the beginning and end of a string


描述

trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] ) : string

参数 character_mask 可指定任意字符,使用..可指定一个范围
默认去除下面五个字符

  • " " (ASCII 32 (0x20)), an ordinary space - 普通空白符.
  • "\t" (ASCII 9 (0x09)), a tab - 制表符.
  • "\n" (ASCII 10 (0x0A)), a new line (line feed) - 换行符.
  • "\r" (ASCII 13 (0x0D)), a carriage return - 回车符.
  • "\0" (ASCII 0 (0x00)), the NUL-byte.
  • "\x0B" (ASCII 11 (0x0B)), a vertical tab - 垂直制表符.

示例

trim($text, " \t.");
trim($hello, "Hdle");
// (from 0 to 31 inclusive)
trim($binary, "\x00..\x1F");

参看

类似函数,ltrim(),rtrim()


PHP trim()函数详解

标签:制表符   0x0d   strip   五个   feed   binary   rri   垂直   The   

原文地址:https://www.cnblogs.com/jiaoran/p/12643589.html


评论


亲,登录后才可以留言!