search
HomeBackend DevelopmentPHP TutorialPHP函数详细辨析之rtrim函数 By ACReaper

PHP函数详细剖析之rtrim函数 By ACReaper

string rtrim (string $str [, string $charlist ] )

这个函数很好理解、r表示右边、trim表示修剪、即右边修剪、默认修剪字符str右边的字符。默认修剪空格字符。

而当指定$charlist时、其修剪方法是一个个字符的匹配。

先从$charlist取第一个字符和$str最后一个匹配、如果匹配则删除$str后面那个字符。

不匹配则接着匹配$charlist的下个字符直到、$charlist被扫描一篇且没有匹配则完成右裁剪。

如果有匹配的则从$charlist的头开始重新和新的$str的尾字符一个个匹配。



例子:

<?php // Example 1:   rtrim('This is a short short sentence', 'short sentence');   // returns 'This is a'   // If you were expecting the result to be 'This is a short ',   // then you're wrong; the exact string, 'short sentence',   // isn't matched.  Remember, character-by-character comparison!   // Example 2:   rtrim('This is a short short sentence', 'cents');   // returns 'This is a short short '?> 

2013 09 11

By ACReaper

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
short占几个字节short占几个字节Feb 01, 2023 am 11:37 AM

short占2个字节;short在C语言中是定义一种整型变量家族的一种;C语言中有三种整数类型,分别为short、int和long;int称为整型,short称为短整型,long称为长整型。

使用PHP函数 "rtrim" 去除字符串右侧的空白字符使用PHP函数 "rtrim" 去除字符串右侧的空白字符Jul 24, 2023 pm 07:53 PM

使用PHP函数"rtrim"去除字符串右侧的空白字符在编写PHP程序时,我们经常需要处理字符串。字符串中可能会包含空白字符,例如空格、制表符和换行符。如果字符串的右侧有空白字符,可能会对我们后续的处理造成麻烦。幸运的是,PHP提供了一个内置函数"rtrim",可以帮助我们快速去除字符串右侧的空白字符。下面是使用"rtrim"函数的使用示例:$str

Java中this方法怎么使用Java中this方法怎么使用Apr 18, 2023 pm 01:58 PM

一、this关键字1.this的类型:哪个对象调用就是哪个对象的引用类型二、用法总结1.this.data;//访问属性2.this.func();//访问方法3.this();//调用本类中其他构造方法三、解释用法1.this.data这种是在成员方法中使用让我们来看看不加this会出现什么样的状况classMyDate{publicintyear;publicintmonth;publicintday;publicvoidsetDate(intyear,intmonth,intday){ye

一篇搞懂this指向,赶超70%的前端人一篇搞懂this指向,赶超70%的前端人Sep 06, 2022 pm 05:03 PM

同事因为this指向的问题卡住的bug,vue2的this指向问题,使用了箭头函数,导致拿不到对应的props。当我给他介绍的时候他竟然不知道,随后也刻意的看了一下前端交流群,至今最起码还有70%以上的前端程序员搞不明白,今天给大家分享一下this指向,如果啥都没学会,请给我一个大嘴巴子。

jQuery中this的使用技巧解析jQuery中this的使用技巧解析Feb 22, 2024 pm 08:54 PM

jQuery是一种流行的JavaScript库,广泛用于网页开发中的DOM操作和事件处理。其中一个重要的概念就是this关键字的使用。在jQuery中,this代表当前操作的DOM元素,但在不同的上下文中,this的指向可能会有所不同。本文将通过具体的代码示例来解析jQuery中this的使用技巧。首先,让我们来看一个简单的示例:

JavaScript箭头函数中的this详解JavaScript箭头函数中的this详解Jan 25, 2024 pm 01:41 PM

JavaScript中箭头函数是一种比较新的语法,没有自己的this关键字,相反箭头函数的this指向包含它的作用域对象,影响方面有:1、箭头函数中的this是静态的;2、箭头函数不能作为构造函数使用;3、箭头函数不能用作方法。

JavaScript如何改变this指向?三种方法浅析JavaScript如何改变this指向?三种方法浅析Sep 19, 2022 am 09:57 AM

JavaScript如何改变this指向?下面本篇文章给大家介绍一下JS改变this指向的三种方法,希望对大家有所帮助!

什么是this?深入解析JavaScript中的this什么是this?深入解析JavaScript中的thisAug 04, 2022 pm 05:02 PM

什么是this?下面本篇文章给大家介绍一下JavaScript中的this,并聊聊this在函数不同调用方式下的区别,希望对大家有所帮助!

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),