Home > Backend Development > PHP Problem > How to remove Chinese colon in php

How to remove Chinese colon in php

WBOY
Release: 2023-03-15 12:24:02
Original
1779 people have browsed it

In PHP, you can use the "preg_replace()" function to remove Chinese colons. This function is used to perform a regular expression search and replacement. When the parameter is set to "'/:/'", You can remove the Chinese colon, the syntax is "preg_replace('/:/', '', $str)".

How to remove Chinese colon in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to remove Chinese colons in php

preg_replace function performs a regular expression search and replacement.

Syntax

mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
Copy after login

Search for the part of subject that matches pattern and replace it with replacement.

Parameter description:

$pattern: The pattern to be searched, which can be a string or a string array.

$replacement: String or array of strings used for replacement.

$subject: The target string or string array to be searched and replaced.

$limit: Optional, the maximum number of substitutions for each subject string per pattern. The default is -1 (no limit).

$count: Optional, the number of times the replacement is performed.

Return value

If subject is an array, preg_replace() returns an array, otherwise it returns a string.

If a match is found, the replaced subject is returned, otherwise the unchanged subject is returned. If an error occurs, NULL is returned.

The example is as follows:

<?php
$str = &#39;他说:没问题&#39;;
$str = preg_replace(&#39;/:/&#39;, &#39;&#39;, $str);
echo $str;
?>
Copy after login

Output result:

How to remove Chinese colon in php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to remove Chinese colon 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