PHP removes the last character substr () of the string.
use today, remove the last character in the string,
the original string 1,2,3,4,5,6,
remove the last character.Quot;.Quot; the final result is 1,2,3,4,5,6
code as follows:
copy code as follows:
$str =.Quot; 1,2,3,4,5,6,.Quot;
$newstr = substr ($str, 0, strlen ($str) -1).
syntax: String substr (string string, int start, int [length]);
return value: string
function category: data processing
content / > this function takes the character string from the string from the string. If start is negative, it is calculated from the end of the string. If the parameter length can be omitted, but it is negative, it means that the countdown length character is taken.
use example
to copy code code as follows:
[code].lt;
echo substr (.Quot; abcdef.quot; 1, 3); / / / / return.Quot; Uot; abcdef.quot; 1, -1); / / / return.Quot; bcde.quot;
.Gt; [/code]
PHP rtrim () function
definition and usage () function begins to delete blank characters or other predefined characters from the end of the string. The same chop () function. The
syntax
rtrim (string, charlist) parameter describes the necessity of
string. A string that specifies to be converted.
charlist is optional. Specify which characters are deleted from the string.
if this parameter is not set, all of the following characters are deleted:
.quot; \0.quot; - ASCII 0, NULL
.quot; \t.quot; - ASCII 9, tabs
.quot; \n.quot; - 10