Home > Backend Development > PHP Problem > How to remove a certain character in php

How to remove a certain character in php

藏色散人
Release: 2023-03-04 06:56:01
Original
4031 people have browsed it

How to remove a certain character in php: 1. Use the "str_replace("123", "", $str);" method to delete the specified string; 2. Use "preg_replace("#abc#i ", "", $str);" method removes specified characters.

How to remove a certain character in php

Recommended: "PHP Video Tutorial"

You can use the str_replace function or preg_replace function to replace the specified string with Empty, that is to say, delete the specified string:

<?php
$str = &#39;a123abc112233aaccdd321123abcd&#39;;
echo str_replace("123", "", $str);
//输出:aabc112233aaccdd321abcd a123112233/aiezu.com/aaccdd321123d
 
$str = &#39;a123abc112233/aiezu.com/aaccdd321123abcd&#39;;
echo preg_replace("#abc#i", "", $str);
//输出:a123112233/aiezu.com/aaccdd321123d
Copy after login

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

Related labels:
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