Home  >  Article  >  Backend Development  >  字符串如何匹配数组和?

字符串如何匹配数组和?

WBOY
WBOYOriginal
2016-06-23 14:00:191379browse

$a = 'abc123';  // 字符串如何匹配如下数组?Array(    [0] => abc123    [1] => 1231231    [2] => 123123123    [3] => 222aads2    [4] => 23232    [8] => 222211    [9] => asfds) 个数  前后  字母  大小写   都要匹配  如果匹配其中一个返回  true  否则 返回 false


回复讨论(解决方案)

匹配是指在数组中?
in_array()?

$a = 'abc123';$arr = Array(    0 => 'abc123',    1 => '1231231',    2 => '123123123',    3 => '222aads2',    4 => '23232',    8 => '222211',    9 => 'asfds') ;if(in_array($a, $arr)){	echo '匹配成功';}else{	echo '匹配失败';}

$a = 'abc123';$arr = Array(    0 => 'abc123',    1 => '1231231',    2 => '123123123',    3 => '222aads2',    4 => '23232',    8 => '222211',    9 => 'asfds') ;if(in_array($a, $arr)){	echo '匹配成功';}else{	echo '匹配失败';}


就是忘记了  in_array  一时半会想不起来 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn