How to remove angle brackets in php

藏色散人
Release: 2023-03-12 15:56:01
Original
2247 people have browsed it

php method to remove angle brackets: 1. Define a string containing angle brackets; 2. Pass "str_replace(array('<', '>'),array('', '' ), $content);" just remove the angle brackets.

How to remove angle brackets in php

The operating environment of this article: Windows7 system, PHP7.1 version, Dell G3 computer

How to remove the angle brackets in php?

The code is as follows:

<?php
$content = &#39;<哈哈>&#39;;
$content = str_replace(array(&#39;<&#39;, &#39;>&#39;),array(&#39;&#39;, &#39;&#39;), $content);
var_dump($content);
Copy after login

The output result is as follows:

string &#39;哈哈&#39; (length=6)
Copy after login

str_replace() The function replaces some characters in the string (case sensitive).

This function must follow the following rules:

If the searched string is an array, then it will return an array.

If the searched string is an array, then it will find and replace each element in the array.

If an array needs to be searched and replaced at the same time, and the elements to be replaced are less than the number of found elements, the excess elements will be replaced with empty strings.

If you search an array and replace only one string, the replacement string will work on all found values.

Note: This function is case-sensitive. Please use the str_ireplace() function to perform a case-insensitive search.

Note: This function is binary safe.

Recommended learning: "PHP Video Tutorial"

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