如何用数组检查php变量?
$user_check = "ccc";
<?php
$user_group = array('aaa' , 'bbb' , 'ccc' , 'ddd');
$name_group = join("','",$user_group);
if ($name_group != $user_check) {
echo "not found."
} else {
echo "found."
}
?>
答案 0 :(得分:4)
尝试in_array()
if (in_array($user_check,$user_group))
{ echo "found."; }
else
{ echo "Not found."; }
查看此link上的文档。
答案 1 :(得分:0)
使用in_array
功能
if ( in_array($user_check, $user_group) ) {
echo "found."
} else {
echo "not found."
}