Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to replace php without case sensitivity

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you the relevant knowledge points about how to replace php without case sensitivity. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

Replacement method: 1, with str_ireplace (), you can search for the specified value in the array or string and replace it with other values; 2, with substr_replace (), you can replace the characters of the specified length from the specified position; 3, with array_replace (), you will replace the value of the first array with the values of the following array.

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

There are several ways to implement case-insensitive array or string substitution in PHP:

Str_ireplace () function

Substr_replace () function

Array_replace () function

1. Use the str_ireplace () function

The str_ireplace () function replaces some characters in the string (case-insensitive).

The function must follow the following rules:

If the search string is an array, it returns an array.

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

If an array needs to be found and replaced at the same time, and the number of elements that need to be replaced is less than the number of elements found, the extra elements will be replaced with an empty string.

If you are looking for an array, but only one string is replaced, the alternative string will have an effect on all found values.

2. Use the substr_replace () function

The substr_replace () function replaces part of a string with another string.

The substr_replace () function is also case-insensitive because it is replaced not based on the character (substring), but on the position of the character.

Replaces characters of the specified length from the specified position.

3. Use the array_replace () function

The array_replace () function replaces the value of the first array with the value of the following array.

The array_replace () function is also case-insensitive because when it is replaced, it is not based on characters.

These are all the contents of the article "how php is replaced and case insensitive". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report