$SA_IP=北京市;
$citya =北京市,天津市;
$cityb =上海市,深圳市;
$citys =$citya+$cityb;
if($SA_IP==$citys){// 表示找到匹 ?>
}?>
就是当$SA_IP=北京市;,条件真。当$SA_IP=天津市;,条件真。 当$SA_IP=深圳市; ,条件真。
SQL有个like %% 可以模糊查询,就是我现在用PHP要怎么样去实现。
回复讨论(解决方案)
strpos
header ( 'Content-Type:text/html;charset=utf-8' );$SA_IP = '北京市';$citys = '北京市,天津市,上海市,深圳市';if (strpos ( $citys, $SA_IP ) !== false) {echo '存在';} else {echo '不存在';}
strpos楼上正解
header ( 'Content-Type:text/html;charset=utf-8' );$SA_IP = '北京市';$citys = '北京市,天津市,上海市,深圳市';if (strpos ( $citys, $SA_IP ) !== false) {echo '存在';} else {echo '不存在';}
$citya =北京市,天津市;
$cityb =上海市,深圳市;
$citys =$citya+$cityb;
$citys的数据是这$citya $cityb 相加的数据,能相加吗
header ( 'Content-Type:text/html;charset=utf-8' );$SA_IP = '北京市';$citys = '北京市,天津市,上海市,深圳市';if (strpos ( $citys, $SA_IP ) !== false) {echo '存在';} else {echo '不存在';}
谢谢 使用 $citys =$citya.$cityb; 就相加了
本文原创发布php中文网,转载请注明出处,感谢您的尊重!