Php code for deleting the last character of a string-PHP Tutorial

Source: Internet
Author: User
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 ,...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.