ltrim

  • (PHP 4, PHP 5, PHP 7)
  • ltrim — Strip whitespace (or other characters) from the beginning of a string
  • ltrim — 删除字符串开头的空白字符(或其他字符)

Description

string ltrim ( string $str [, string $character_mask ] )
//Strip whitespace (or other characters) from the beginning of a string.
//删除字符串开头的空白字符(或其他字符)

Parameters

str

  • The input string.
  • 输入的字符串。

character_mask

  • You can also specify the characters you want to strip, by means of the character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.
  • 通过参数 character_mask,你也可以指定想要删除的字符,简单地列出你想要删除的所有字符即可。使用..,可以指定字符的范围。

Return Values

  • This function returns a string with whitespace stripped from the beginning of str. Without the second parameter, ltrim() will strip these characters:
  • 该函数返回一个删除了 str 最左边的空白字符的字符串。 如果不使用第二个参数, ltrim() 仅删除以下字符:
  • " " (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.NUL空字节符。
  • "\x0B" (ASCII 11 (0x0B)), a vertical tab.垂直制表符。

Examples

<?php
/**
* Created by PhpStorm.
* User: zhangrongxiang
* Date: 2018/3/4
* Time: 下午4:37
*/ //ltrim — 删除字符串开头的空白字符(或其他字符) $hello = "Hello World";
//Hello World
echo ltrim( $hello ) . PHP_EOL;
//ello World
echo ltrim( $hello, 'H' ) . PHP_EOL;
//llo World
echo ltrim( $hello, 'eH' ) . PHP_EOL; $text = "\t\tThese are a few words :) ... ";
// These are a few words :) ...
echo $text . PHP_EOL;
//These are a few words :) ...
echo ltrim( $text ) . PHP_EOL;
//These are a few words :) ...
echo ltrim( $text, "\t" ) . PHP_EOL;
// These are a few words :) ...
echo ltrim( $text, '\t' ) . PHP_EOL; $binary = "\x09Example string\x0A";
// Example string
//
echo $binary . PHP_EOL;
//Example string
//
echo ltrim( $binary ) . PHP_EOL;
//Example string
//
echo ltrim( $binary, "\x00..\x1F" ) . PHP_EOL;

See

All rights reserved

PHP之string之ltrim()函数使用的更多相关文章

  1. [PHP源码阅读]trim、rtrim、ltrim函数

    trim系列函数是用于去除字符串中首尾的空格或其他字符.ltrim函数只去除掉字符串首部的字符,rtrim函数只去除字符串尾部的字符. 我在github有对PHP源码更详细的注解.感兴趣的可以围观一下 ...

  2. php ltrim()函数 语法

    php ltrim()函数 语法 ltrim()函数怎么用? php ltrim()函数用于删除字符串左边的空格或其他预定义字符,语法是ltrim(string,charlist),返回经过charl ...

  3. OC与c混编实现Java的String的hashcode()函数

    首先,我不愿意大家需要用到这篇文章里的代码,因为基本上你就是被坑了. 起因:我被Java后台人员坑了一把,他们要对请求的参数增加一个额外的字段,字段的用途是来校验其余的参数是否再传递过程中被篡改或因为 ...

  4. string类find函数返回值判定

     string类find函数返回值判定 代码示例 #include<iostream> #include<cstring> using namespace std; int m ...

  5. C string.h 常用函数

    参考:http://womendu.iteye.com/blog/1218155 http://blog.csdn.net/zccst/article/details/4294565 还有一些,忘记了 ...

  6. c++中string的常用函数说明

    string可以说是是字符数组的升级版,使用更加啊方便,不容易出错.本文对string的常用函数进行简单介绍,做到会用即可. string中的常用函数分为四类,即赋值,添加,比较和删除. 一.赋值 1 ...

  7. C++ string类及其函数的讲解

    文章来源于:http://www.cnblogs.com/hailexuexi/archive/2012/02/01/2334183.html C++中string是标准库中一种容器,相当于保存元素类 ...

  8. [转载]Oracle ltrim() 函数用法

    前面有说到过LPAD和RPAD这两个函数用法的文章,今天发现与之相反意义的另外两个函数,那就是LTRIM() RTRIM(). 这次就挑LTRIM() 这一函数来讲讲: 具体的语法格式如下: LTRI ...

  9. PHP之string之explode()函数使用

    explode (PHP 4, PHP 5, PHP 7) explode - Split a string by string explode - 使用一个字符串分割另一个字符串 Descripti ...

随机推荐

  1. 8.使用Exists监控ZNode的三大Change事件

    一. zookeeper是一个分布式的协调程序(所有程序都是通过订阅它来相互感知)   1. tcp(长链接) + watcher server ->client client ->ser ...

  2. [C#]如何解决修改注册表受限问题(转)

    在项目中添加一个Application Manifest File,名字默认为app.manifest,内容中应该有一行: <requestedExecutionLevellevel=" ...

  3. centos mysql忘记密码找回(仅限mysql5.7)

    1.停掉mysql 2.执行#mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 3.#mysql 4.updat ...

  4. 转载:oracle 自定义类型 type / create type

    标签:type create oracle object record 一:Oracle中的类型有很多种,主要可以分为以下几类: 1.字符串类型.如:char.nchar.varchar2.nvarc ...

  5. 购买小米成功 散分mhn

    之前,我们都没办法解决近来的寡言,面对越来越少的语言,只能是憋得气闷.却没想后来这么一件事可以解开那个尴尬. 前两天晚上,他被我一次次闪躲去看小说伤害,难受,却还是不想和我争吵什么.后来,偶然的机会让 ...

  6. Net特性类Description了解下

    NET特性类都有个特点类名+Attribute,继承基类Attribute,我们看下微软自带的特性类:DescriptionAttribute namespace System.ComponentMo ...

  7. JgrId 无数据返回设置

    在addJSONData方法中 while (i < len) { 前增加以下代码 ) { rowData.push('<tr role="row" id=" ...

  8. Java基础知识点1

    运算符 运算符的分类: 算术运算符 赋值运算符 关系运算符 逻辑运算符 位运算符 三目运算符 自增自减运算符:++i:i先自加,再做其他运算:i++先运算再自加: --i先自减再做其他运算:i--先运 ...

  9. Python3.5 学习三

    对文件的操作 打开模式: 1 f=open("xxx","r",encoding=="utf-8") 只读 2 f=open("x ...

  10. A - 还是畅通工程(最小生成树)

    点击打开链接 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离.省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并 ...