Home  >  Article  >  Backend Development  >  How to find substrings in PHP strings without case sensitivity?

How to find substrings in PHP strings without case sensitivity?

青灯夜游
青灯夜游Original
2020-07-17 14:11:122839browse

In PHP, you can use the stristr() function to find another substring in a string without case sensitivity. Returns the remainder of the string (from the matching point) if the lookup is successful, or false if the string is not found.

How to find substrings in PHP strings without case sensitivity?

In PHP, the stristr() function is used to find another string in a string without case sensitivity. [Related recommendations: PHP Tutorial]

If the search is successful, the rest of the string (from the matching point) is returned. If the string is not found, false is returned.

Syntax

stristr(string,search,before_search)

How to find substrings in PHP strings without case sensitivity?

Example: Return the part of the string before the first occurrence of "world" :

<!DOCTYPE html>
<html>
<body>

<?php
echo stristr("Hello world!","WORLD",true);
?>

</body>
</html>

Result:

Hello

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of How to find substrings in PHP strings without case sensitivity?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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