字符串如何匹配数组和?

WBOY
Release: 2016-06-23 14:00:19
Original
1383 people have browsed it

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


回复讨论(解决方案)

匹配是指在数组中?
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 '匹配失败';}
Copy after login
Copy after login

$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 '匹配失败';}
Copy after login
Copy after login


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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template