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

How to find substrings in PHP strings without case sensitivity?

青灯夜游
Release: 2023-03-02 16:32:02
Original
2929 people have browsed it

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)
Copy after login

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>
Copy after login

Result:

Hello
Copy after login

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!

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