当前位置:网站首页>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.
边栏推荐
猜你喜欢

xxl-job源码解析(技术分享)

Google engineer "code completion" tool; "Transformers NLP" accompanying book code; FastAPI development template; PyTorch model acceleration tool; cutting-edge papers | ShowMeAI News Daily

Placement Rules 使用文档

Golang分布式应用定时任务如何实现

【HMS core】【FAQ】push kit、WisePlay DRM、Location Kit、Health Kit、3D Modeling Kit、SignPal Kit典型问题合集4

CAD几个优化设置

PMP每日一练 | 考试不迷路-7.30(包含敏捷+多选)

【C语言】指针和数组的深入理解(第二期)
![[AGC] Quality Service 1 - Example of Crash Service](/img/d8/e6b365889449745a61597b668dc89b.png)
[AGC] Quality Service 1 - Example of Crash Service
![[Cloud Native] Service Industry Case - Solutions for Unpredictable Concurrency Scenarios](/img/c7/3faa29dc374e2e16e59ac9b8ebf249.png)
[Cloud Native] Service Industry Case - Solutions for Unpredictable Concurrency Scenarios
随机推荐
Nature Microbiology综述:聚焦藻际--浮游植物和细菌互作的生态界面
TiUP 故障排查
How to split microservices?
Applicable scenarios of TiDB tools
Compile, link, notes - 3
【HMS core】【Media】【Video Editing Service】 The online material cannot be displayed, it is always in the loading state or the network is abnormal
arcpy使用教程
华为ADS获取转化跟踪参数报错:getInstallReferrer IOException: getInstallReferrer not found installreferrer
tiup install
vite 多页面应用刷新页面时,不会在当前路由中,会返回到根路由
100w的数据表比1000w的数据表查询更快吗?
How to do a good job in technology selection
Load Base Split 使用文档
[Cloud Native] Service Industry Case - Solutions for Unpredictable Concurrency Scenarios
70 lines of code, a desktop automatic translation artifact
C# List<T> 模板的案例
(Popular Science) What is Fractional NFT (Fractional NFT)
Core Topics under Microservice Architecture (2): Design Principles and Core Topics of Microservice Architecture
Back waves are coming!Ali produced the "second generation" container technical manual and brain map, which is too fragrant
应用接入华为分析在应用调试模式下为何没有数据上报?