php - 是否有一种简化的方法来检查字符串数组的每个索引?
问题描述
例如我有这个字符串
$string = "HelloWorld";
我想检查前四个字母是否等于“地狱”
if($string[0]=="H"&&$string[1]=="e"&&$string[2]=="l"&&$string[3]=="l");
有没有更好或简化的检查方法?也许 $string[0-4] 或类似的东西
解决方案
推荐阅读
- calculator - 制作在javascript中的整数后仅显示2位小数
- python - 使用 beautifulsoup 抓取 merriam-webster
- ionic-framework - fast-exif 如何在 ionic 4 下工作?
- c# - 有没有办法在纯 C# 中从 Chrome 浏览器中获取元素,没有 Selenium
- c# - Why is my DataGrid showing up in the wrong Grid column?
- javascript - ES2015 函数名推断在哪里定义?
- javascript - 超过最大执行时间谷歌表格脚本解决方法
- asp.net-core - RestSharp 响应错误:“每个套接字地址(协议/网络地址/端口)通常只允许使用一次”
- javascript - 单击按钮时如何使一堆输入消失
- javascript - Javascript 枚举数组