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

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

问题描述

在 php 中,我想知道如何检查一个变量是否等于列表中的任何变量.

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

我想我可以尝试类似的东西

I thought I could try something like

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天全站免登陆