看看一个变量等于列表中的PHP中的任何其他变量 [英] see if a variable equals any other variables in a list php

查看:91
本文介绍了看看一个变量等于列表中的PHP中的任何其他变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中,我不知道我怎样检查是否一个变量等于任何变量在列表中。

In php, I was wondering how I check if a variable equals any of the variables in a list.

我想我可以尝试像

if( $example == array($one, $two, $three, $four, $five) ) {
    //code here
}

这没有工作,有没有这样做的一个类似的方式?否则,这将是做到这一点的最好方法是什么?

This didn't work, is there a similar way of doing it? Otherwise, what would be the best way to do it?

推荐答案

你的意思是这样的 in_array() 功能?

Do you mean something like in_array() function?

if( in_array($example, array($one, $two, $three, $four, $five)) ) {
    //code here
}

这篇关于看看一个变量等于列表中的PHP中的任何其他变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆