Home  >  Article  >  Backend Development  >  How to replace the last character in php

How to replace the last character in php

藏色散人
藏色散人Original
2020-11-19 10:14:102296browse

php method to replace the last character: first create a PHP sample file; then use the regular expression "preg_replace('#.$#i', '0', $image_path);" to replace the last character of the string Just replace it.

How to replace the last character in php

Recommendation: "PHP Video Tutorial"

The operating environment of this tutorial: Windows 7 system, PHP version 5.6, This method works for all brands of computers.

php method to replace the last character:

PHP intercepts the last character of the string and replaces it

The code is as follows:

$image_path = 'http://www.baidu.com/1';

$str = preg_replace('#.$#i', '0', $image_path);The content to be replaced in the second parameter

Change 1 to 0

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

Statement:
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