Php deletes the code of the program with the last character of the string. This is the simplest php getting started tutorial. we only need to know a few common functions to delete the last character of the string, such as substr and rtrim. The original string 1, 2, 3 is the simplest php getting started tutorial. we only need to know a few common functions to delete the last character of the string, such as substr and rtrim.
Original String 1, 2, 3, 4, 5, 6,
Remove the last character "," and the final result is 1, 2, 3, 4, 5, 6.
The code is as follows:
The code is as follows: |
|
$ Str = "1, 2, 3, 4, 5, 6 ,"; $ Newstr = substr ($ str, 0, strlen ($ str)-1 ); Echo $ newstr; // echo 1, 2, 3, 4, 5, 6 |
The built-in functions of the system can achieve this effect in two ways:
1) substr ($ str, 0,-1)
2) rtrim ($ str ,",")
The above example only describes the use of php functions. we can also use a lot of methods to achieve this. here we will not mention the most basic php Getting Started Tutorial.
Bytes. Original String 1, 2, 3 ,...