定义和用法

trim() 函数从字符串的两端删除空白字符和其他预定义字符。

语法

trim(string,charlist)
参数 描述
string 必需。规定要检查的字符串。
charlist 可选。规定要转换的字符串。如果省略该参数,则删除以下所有字符:

  • “\0” – NULL
  • “\t” – tab
  • “\n” – new line
  • “\x0B” – 纵向列表符
  • “\r” – 回车
  • ” ” – 普通空白字符

例子

例子 1

“`

“;
echo “With trim: ” . trim($str);
?>

“`
输出:

Without trim: Hello World!
With trim: Hello World!

HTML 源码:

<html>
<body>
Without trim:     Hello World!    <br />With trim: Hello World!
</body>
</html>

例子 2


";
echo "With trim: " . trim($str);
?>

Without trim: Hello World!
With trim: Hello World!

HTML 源码:

<html>
<body>
Without trim: 
Hello World!
<br />With trim: Hello World!
</body>
</html>

记录一个laravel-excel导出表格值为0导出excel显示空的解决方法。

最近在使用laravel-excel导出表格的时候,发现假如字段值为0的情况下,导出的excel中直接显示为空,找到一个方法解决,如下. 在laravel-excel的config配置中...

阅读全文

php实现redis延时队列

写了一个简单的类实现 使用方法 $class = new RedisDelayQueue(); $class->execute(); <?php namespace app\common\service; class RedisDelay { ...

阅读全文

php获取包含10w个手机号的txt文件(逗号隔开)

txt文件格式如下 13000000000,13000000005,13000000403,13001010129,13001010688,13001010838,13001016389,13001019538,13001030005,13001042700,13001047495...

阅读全文

欢迎留言