当前位置:网站首页>php how to query string occurrence position
php how to query string occurrence position
2022-07-30 15:56:00 【Million speed cloud】
How does php query where the string appears
This article will introduce "how to query the location of strings in php" in detail. The content is detailed, the steps are clear, and the details are handled properly. I hope this article "How to query the location of strings in php" can helpLet’s solve your doubts, follow the ideas of the editor to slowly deepen, and let’s learn new knowledge together.
4 methods: 1. Use stripos() to return the position of the first occurrence (case-insensitive), syntax "stripos(string, query value)"; 2. Use strpos() to return the first occurrenceThe position of the second occurrence (case sensitive), the syntax "strpos(string, query value)"; 3. Use strripos() to return the position of the last occurrence, the syntax "strpos(string, query value)"; 4.With strrpos(), the syntax "strrpos(string, query value)".

The operating environment of this tutorial: windows7 system, PHP8.1 version, DELL G3 computer
Method 1: Use the stripos() function
Thestripos() function finds the first occurrence of a string within another string (case-insensitive).
Return value: Returns the position of the first occurrence of the string in another string, or FALSE if the string is not found.Note: String positions start at 0, not 1.
";$find="world";echo "Specify where the substring world appears: ".stripos($str,$find);?>

Method 2: Use the strpos() function
Thestrpos() function finds the first occurrence of a string within another string (case-sensitive).
Return value: Returns the position of the first occurrence of the string in another string, or FALSE if the string is not found.
";$find1="php";echo "Specify where the substring php appears: ".strpos($str,$find1)."
";$find2="PHP";echo "Specify where the substring PHP appears: ".strpos($str,$find2);?>

Method 3: Use the strripos() function
Thestrripos() function finds the last occurrence of a string within another string (case-insensitive).
Return value: Returns the position of the last occurrence of the string in another string, or FALSE if the string is not found.
";$find1="php";echo "Specify where the substring php appears: ".strripos($str,$find1)."
";$find2="PHP";echo "Specify where the substring PHP appears: ".strripos($str,$find2);?>

Method 4: Use the strrpos() function
Thestrrpos() function finds the last occurrence of a string within another string (case-sensitive).
Return value: Returns the position of the last occurrence of the string in another string, or FALSE if the string is not found.
";$find1="php";echo "Specify where the substring php appears: ".strrpos($str,$find1)."
";$find2="PHP";echo "Specify where the substring PHP appears: ".strrpos($str,$find2);?>

After reading this, the article "How to Query the Appearance of Strings in PHP" has been introduced. If you want to master the knowledge points of this article, you need to use your own hands to understand it. If you want toFor more related articles, please pay attention to the Yisu Cloud Industry Information Channel.
边栏推荐
猜你喜欢

Placement Rules 使用文档

timed task corn

php如何查询字符串出现位置

华为「天才少年」计划招募的博士们,迎来首秀!
![[Developers must see] [push kit] Collection of typical problems of push service 2](/img/70/d5127d57d2f3532deb7314d737820b.png)
[Developers must see] [push kit] Collection of typical problems of push service 2

哨兵

Why is there no data reported when the application is connected to Huawei Analytics in the application debugging mode?

AL遮天传 DL-深度学习模型的训练技巧

HTTP缓存小结

flask获取post请求参数
随机推荐
vite 多页面应用刷新页面时,不会在当前路由中,会返回到根路由
应用接入华为分析在应用调试模式下为何没有数据上报?
R中按照数字大小进行排序
Why is there no data reported when the application is connected to Huawei Analytics in the application debugging mode?
配置Path环境变量
Promise Notes (1)
Introduction to kasini3000
RobotStudio实现喷漆、打磨等功能(曲面路径生成与仿真)
TiUP 命令概览
tiup env
TiDB 工具适用场景
二、判断 & 循环
Overview of TiUP commands
FME realizes the method of converting CAD with attribute to SHP data
数据库日期类型字段设计,应该如何选择?
L2-007 家庭房产(vector、set、map的使用)
TiDB 工具下载
让人上瘾的新一代开发神器,彻底告别Controller、Service、Dao等方法
影像信息提取DEM
C# List<T> 模板的案例