分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

PHP之string之ltrim()函数使用

发布时间:2023-09-06 01:44责任编辑:赖小花关键词:PHP

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 Worldecho ltrim( $hello ) . PHP_EOL;//ello Worldecho ltrim( $hello, 'H' ) . PHP_EOL;//llo Worldecho 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

  • http://php.net/manual/zh/function.ltrim.php

    All rights reserved

PHP之string之ltrim()函数使用

原文地址:https://www.cnblogs.com/zhangrxiang/p/8505116.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved