How to replace Chinese colon in php

青灯夜游
Release: 2023-03-15 12:46:02
Original
1810 people have browsed it

php method to replace Chinese colon: 1. Use str_ireplace() function, syntax "str_ireplace(Chinese colon, replacement value, $str)"; 2. Use str_replace() function, syntax "str_replace(Chinese colon ,replacement value,$str)”.

How to replace Chinese colon in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In php, you can use str_ireplace() and str_replace() function to replace Chinese colons in strings.

str_ireplace() and str_replace use a new string to replace a specific string specified in the original string. str_replace is case-sensitive, while str_ireplace() is not case-sensitive. The syntax of the two is similar.

The syntax of str_ireplace() is as follows:

mixed str_ireplace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
Copy after login

These two functions return a string or array. This string or array is the result of replacing all search in subject with replace. The parameter count represents the number of times to perform the replacement.

Usage examples are as follows:

<?php  
header("content-type:text/html;charset=utf-8");
$str = &#39;hello:world:hello:world&#39;;
echo "原字符串: ".$str."<br>";
$replace = &#39;-&#39;;
$search = &#39;:&#39;;
echo str_replace($search, $replace, $str)."<br>";
echo str_ireplace($search, $replace, $str);
?>
Copy after login

How to replace Chinese colon in php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to replace Chinese colon 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!