How to remove the last character in php

王林
Release: 2023-03-04 11:20:01
Original
1646 people have browsed it

php method to remove the last character: We can use the rtrim() function to remove the last character. The rtrim() function is used to remove blank characters or other predefined characters on the right side of a string and return the modified string. The usage method is as follows: [rtrim($str,"World!");].

How to remove the last character in php

rtrim() function removes whitespace characters or other predefined characters on the right side of a string and returns the modified string.

(Recommended tutorial:php graphic tutorial)

Syntax:

rtrim(string,charlist)
Copy after login

Parameters:

  • string Required. Specifies the string to check.

  • #charlist Optional. Specifies which characters are removed from a string.

(Video tutorial recommendation:php video tutorial)

Code implementation:

"; echo rtrim($str,"World!"); ?>
Copy after login

Output result:

Hello World! Hello
Copy after login

The above is the detailed content of How to remove the last character in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!