检查字符串是否在PHP中包含字符串

问题描述 投票:0回答:4

我想知道如果该IP地址的字符串为x时,如何检查我的字符串(特别是一个IP地址)>

例如

$ip = "66.124.61.23" // ip of the current user
$x = "66.124" // this is the string what I want to check in my $ip.

所以如何检查$ ip是否包含$ x的字符串?

如果您很难理解这种情况,请发表评论。

谢谢。

我想知道如果该IP地址的字符串为x,如何检查我的字符串(特别是IP地址),例如$ ip =“ 66.124.61.23” //当前用户的ip $ x =“ 66.124 “ //这是...

php mysql string
4个回答
4
投票

使用strstr()


3
投票

使用strpos()


2
投票

使用stristr()


2
投票

您也可以使用strpos(),并且如果您要查找字符串的开头(如您的示例):

© www.soinside.com 2019 - 2024. All rights reserved.