Home > Backend Development > PHP Tutorial > PHP removes the last character from a string_PHP tutorial

PHP removes the last character from a string_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:51:29
Original
984 people have browsed it

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:

$str = "1,2,3,4,5,6,";
$newstr = substr($str,0,strlen($str)-1);
echo $newstr;
//echo 1,2,3,4,5,6

The function that comes with the system can achieve this effect, two methods:
1) substr($str, 0, -1)
2)rtrim($str, ",")


Excerpted from 〃Style ひぐ

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478188.htmlTechArticleOriginal 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: $str = 1,2,3,4,5,6,; $newstr = substr($str,0,strlen($str)-1); echo $newstr; //echo 1...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template