字符串A:"1,3,4,5,6,7,8,9,10,11,12,14,15,17,20,22,123,457",例如我想知道这个字符串里面是否含有"2",这时候"12","20","22"等.
-
-
- if(in_array('2',explode(',',$str))
-
-
-
- $str= '1,3,4,5,6,7,8,9,10,11,12,14,15,17,20,22,123,457';
- if(strpos(',' . $str . ',', ',2,') !== false)
- {
-
- }
-
-
-
- echo preg_match('/(?<=^|,)2(?=,|$)/','1,3,4,5,6,7,8,9,10,11,12,14,15,17,20,22,123,457');
|