Php in addition to strings-php Tutorial

Source: Internet
Author: User
Php removes the string used in today's project, removes the last character in the string from the original string 1, 2, 3, 4, 5, 6, and removes the last character. The final result is 1, 2, 3, 4, 5, 6. the code is as follows: $ str1, 2, 3, 4, 5, 6,; $ newstrsubstr ($ str, 0, strlen ($ str)-1); echo $ newstr; remove the string from the built-in function php.

Used in today's project to remove the last character in the string

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;

The built-in functions of the system can also achieve the following two methods:

1) substr ($ str, 0,-1)

2) rtrim ($ str ,",")

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.