PHP之string之ltrim()函数使用
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()函数使用的更多相关文章
- [PHP源码阅读]trim、rtrim、ltrim函数
trim系列函数是用于去除字符串中首尾的空格或其他字符.ltrim函数只去除掉字符串首部的字符,rtrim函数只去除字符串尾部的字符. 我在github有对PHP源码更详细的注解.感兴趣的可以围观一下 ...
- php ltrim()函数 语法
php ltrim()函数 语法 ltrim()函数怎么用? php ltrim()函数用于删除字符串左边的空格或其他预定义字符,语法是ltrim(string,charlist),返回经过charl ...
- OC与c混编实现Java的String的hashcode()函数
首先,我不愿意大家需要用到这篇文章里的代码,因为基本上你就是被坑了. 起因:我被Java后台人员坑了一把,他们要对请求的参数增加一个额外的字段,字段的用途是来校验其余的参数是否再传递过程中被篡改或因为 ...
- string类find函数返回值判定
string类find函数返回值判定 代码示例 #include<iostream> #include<cstring> using namespace std; int m ...
- C string.h 常用函数
参考:http://womendu.iteye.com/blog/1218155 http://blog.csdn.net/zccst/article/details/4294565 还有一些,忘记了 ...
- c++中string的常用函数说明
string可以说是是字符数组的升级版,使用更加啊方便,不容易出错.本文对string的常用函数进行简单介绍,做到会用即可. string中的常用函数分为四类,即赋值,添加,比较和删除. 一.赋值 1 ...
- C++ string类及其函数的讲解
文章来源于:http://www.cnblogs.com/hailexuexi/archive/2012/02/01/2334183.html C++中string是标准库中一种容器,相当于保存元素类 ...
- [转载]Oracle ltrim() 函数用法
前面有说到过LPAD和RPAD这两个函数用法的文章,今天发现与之相反意义的另外两个函数,那就是LTRIM() RTRIM(). 这次就挑LTRIM() 这一函数来讲讲: 具体的语法格式如下: LTRI ...
- PHP之string之explode()函数使用
explode (PHP 4, PHP 5, PHP 7) explode - Split a string by string explode - 使用一个字符串分割另一个字符串 Descripti ...
随机推荐
- Objective-C 学习笔记(二) 函数
Objective-C 函数 定义一个方法 在Objective-C编程的方法定义的一般形式如下: - (return_type) method_name:( argumentType1 )argum ...
- Last-Modified Header in Asp.net Core MVC
public class YourController : Controller { public ActionResult MyPage(string id) { var entity = _db. ...
- Firefox mobile (android) and orientationchange
Firefox for Android does not support the orientationchange event but you can achieve the same result ...
- XML--修改XML数据
DECLARE @xmlDoc XMLset @xmlDoc='<root> <book id="0001"> <title>C# Progra ...
- CSS3 线性渐变linear-gradient
CSS3 Gradient 分为 linear-gradient(线性渐变)和 radial-gradient(径 向渐变).为了更好的应用 CSS3 Gradient,需要先了解一下目前的几种现代浏 ...
- 关于Unity中MonoBehaviour的构造函数
关于Unity中MonoBehaviour的构造函数 在学习Unity MVVM UI框架的时候,一不小给一个继承自MonoBehaviour类的子类编写了自定义构造函数,结果调Bug调了两个钟,特此 ...
- sharepoint 2007 update sharepoint 2013 found old privillege not availabel
我们下面提及的升级方式是: 2007 > 2010 > 2013 > 2013: classic authentication à claims based authenticati ...
- python--函数名的使用,闭包,迭代器
1.函数名的使用和第一类对象 函数名是一个变量,但它是一个特殊的变量,与括号配合可以执行函数 函数对象可以像变量一样进行赋值,还可以作为列表的元素进行使用,可以作为返回值返回,可以作为参数进行传递 1 ...
- guzzle 简单使用记录
用 guzzle 发送一个包含指定请求头,请求体的 post 请求,并获取指定内容: <?php include_once "guzzle.phar"; use Guzzle ...
- 关于gcd和exgcd的一点心得,保证看不懂(滑稽)
网上看了半天……还是没把欧几里得算法和扩展欧几里得算法给弄明白…… 然后想了想自己写一篇文章好了…… 参考文献:https://www.cnblogs.com/hadilo/p/5914302.htm ...