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

How to replace the last character in php

藏色散人
Release: 2023-03-07 17:22:01
Original
2314 people have browsed it

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';
Copy after login

$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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template