How php substr () removes the last character
This article mainly explains "php substr() how to remove the last character". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and study and learn "php substr() how to remove the last character" together!
In php, to remove the last character of a string using the substr() function, you simply set the second argument to 0 and the third argument to the string length minus one; the syntax is "substr($string,0,strlen($string)-1)."
Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer
php substr() removes the last character
The substr() function intercepts a specified length of characters from a specified position in a string and returns. The syntax is as follows:
substr($string, $start , $length)
$string: string to be truncated, the string contains at least one character;
$start: the starting position of the truncated string;
$length: Optional parameter indicating the length of the truncated string.
To remove the last digit of a string using the substr() function, you simply set the second argument,$start, to 0 and the third argument,$length, to the length of the string minus one.
Implementation code:
Thank you for reading, the above is "php substr() how to remove the last character" content, after the study of this article, I believe that everyone on php substr() how to remove the last character This problem has a deeper understanding, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!