PHP函数详细辨析之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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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 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

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.

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

jQuery is a popular JavaScript library widely used for DOM manipulation and event handling in web development. One of the important concepts is the use of this keyword. In jQuery, this represents the DOM element currently being operated on, but in different contexts, the pointer of this may be different. This article will analyze the usage skills of this in jQuery through specific code examples. First, let's look at a simple example:

The arrow function in JavaScript is a relatively new syntax. It does not have its own this keyword. On the contrary, the this of the arrow function points to the scope object containing it. The impacts are: 1. This in the arrow function is static; 2. Arrow Functions cannot be used as constructors; 3. Arrow functions cannot be used as methods.

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 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!
