Home Backend Development PHP Tutorial PHP函数详细辨析之rtrim函数 By ACReaper

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

Jun 13, 2016 pm 12:38 PM
rtrim short this

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 '
?> 
Copy after login

2013 09 11

By ACReaper

Statement of this Website
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

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)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

An article that understands this point and catches up with 70% of front-end people An article that understands this point and catches up with 70% of front-end people Sep 06, 2022 pm 05:03 PM

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.

Let's talk about why Vue2 can access properties in various options through this Let's talk about why Vue2 can access properties in various options through this Dec 08, 2022 pm 08:22 PM

This article will help you interpret the vue source code and introduce why you can use this to access properties in various options in Vue2. I hope it will be helpful to everyone!

How many bytes does short occupy? How many bytes does short occupy? Feb 01, 2023 am 11:37 AM

short occupies 2 bytes; short is a type of integer variable family defined in C language; there are three integer types in C language, namely short, int and long; int is called an integer type, and short is called a short Integer type, long is called long integer type.

Use PHP function 'rtrim' to remove whitespace characters on the right side of a string Use PHP function 'rtrim' to remove whitespace characters on the right side of a string Jul 24, 2023 pm 07:53 PM

Use the PHP function "rtrim" to remove whitespace characters on the right side of a string. When writing PHP programs, we often need to process strings. The string may contain whitespace characters such as spaces, tabs, and newlines. If there are blank characters on the right side of the string, it may cause trouble for our subsequent processing. Fortunately, PHP provides a built-in function "rtrim" that can help us quickly remove whitespace characters on the right side of the string. The following is an example of using the "rtrim" function: $str

Clever way to use this keyword in jQuery Clever way to use this keyword in jQuery Feb 25, 2024 pm 04:09 PM

Flexible use of this keyword in jQuery In jQuery, the this keyword is a very important and flexible concept. It is used to refer to the DOM element currently being manipulated. By rationally using this keyword, we can easily operate elements on the page and achieve various interactive effects and functions. This article will combine specific code examples to introduce the flexible use of this keyword in jQuery. Simple this example First, let's look at a simple this example. Suppose we have a

What is this? An in-depth analysis of this in JavaScript What is this? An in-depth analysis of this in JavaScript Aug 04, 2022 pm 05:02 PM

What is this? The following article will introduce you to this in JavaScript, and talk about the differences between this in different calling methods of functions. I hope it will be helpful to you!

How to use this method in Java How to use this method in Java Apr 18, 2023 pm 01:58 PM

1. this keyword 1. Type of this: Which object is called is the reference type of that object 2. Usage summary 1. this.data;//Access attribute 2. this.func();//Access method 3.this( );//Call other constructors in this class 3. Explanation of usage 1.this.data is used in member methods. Let us see what will happen if this is not added classMyDate{publicintyear;publicintmonth;publicintday; publicvoidsetDate(intyear,intmonth,intday){ye

How does JavaScript change this pointer? Brief analysis of three methods How does JavaScript change this pointer? Brief analysis of three methods Sep 19, 2022 am 09:57 AM

How does JavaScript change this pointer? The following article will introduce to you three methods of changing this pointer in JS. I hope it will be helpful to you!

See all articles