Analysis of weird phenomena in the use of PHP function rtrim (), phprtrim
This article describes how to use the PHP function rtrim. We will share this with you for your reference. The details are as follows:
Use todayRtrim ()
The function encountered a strange problem:
Echo rtrim ('<p> </div>', '</div>'); // The output is <pecho ltrim ('www .jb51.net ', 'www. '); // The output is jb51.net.
The above output results are a little surprising. Originally, I thought the first line should be output <p>, and the second line should output jb51.net.
I have been entangled in this problem for a long time, but I have not found the cause. Later I found the answer in the manual:
Rtrim () is replaced by characters rather than strings. When you replace from right to left, the six characters </div> will be replaced, and then the six characters will be replaced, because> is also included in rtirm () in the string (</div>) of the second parameter, so it is replaced, and p is encountered when going to the left, p is not included in the string of the second parameter. So the replacement is stopped, and <p is output.
If you understand this, the output result of the second line is expected. Haha ...... The manual has been clearly written. Original article:
You can also specify the characters you want to strip, by means of the charlist parameter. Simply list all characters that you want to be stripped. With... you can specify a range of characters.
As you can see,Rtrim
,Ltrim
AndTrim
The second parameter matches a group of characters. This is what we have known beforeStr_replace
Function replacement operations are different.