php - 为什么这个 if 语句返回 true?
问题描述
为什么这会返回真实?Party Bounce 和 Slide 13 x18 不在 if 语句中?
print_r($btypes);
//Array ( [0] => 11x13 Red and Yellow 2 [1] => Party Bounce and Slide 13 x 18 )
if(in_array("12x15 Purple and Yellow 2" || "11x13 Red and Yellow 1" || "12x15 Yellow and Purple old" || "11x13 Red and Yellow 2" || "12x15 Purple and Yellow 1" ,$btypes) &&
in_array("Bootcamp Obstacle Course" || "Terminator Torment Obstacle Course" || "Lizard Obstacle Course" || "Bugs Obstacle Course" || "Nemo Obstacle Course",$btypes))
{
return "Standard Bouncy Castle and an Obstacle Course";
}
谢谢你的帮助
解决方案
更易于管理且更重要的快速解决方案……阅读。
$attributes = [
"12x15 Purple and Yellow 2",
"11x13 Red and Yellow 1",
"12x15 Yellow and Purple old",
"11x13 Red and Yellow 2",
"12x15 Purple and Yellow 1"
];
$types = [
"Bootcamp Obstacle Course",
"Terminator Torment Obstacle Course",
"Lizard Obstacle Course",
"Bugs Obstacle Course",
"Nemo Obstacle Course"
];
if(array_intersect($btypes, $attributes) !== [] && array_intersect($btypes, $types) !== []){
return "Standard Bouncy Castle and an Obstacle Course";
}
推荐阅读
- java - UseContainerSupport VM 参数有什么作用?
- python - 如何纠正返回字符串中子字符串数量的代码?
- java - Android 内容提供商返回错误的联系人 ID
- android - 在片段中使用毕加索
- c# - 创建虚拟智能卡 - '未找到元素。(来自 HRESULT 的异常:0x80070490)'
- ios - ios cloudkit接口有插件吗
- php - 如何在多维数组的所有列中搜索索引
- java - 如何更改 InternalEObject 的 URI
- java - 当我将测试导出到可执行 jar 时,如何在可执行 Jar 文件中包含 Chrome 驱动程序
- java - 从月份编号到月份名称的时间?