Rao*_*ito -1 php arrays if-statement
我想知道在PHP中执行这样的代码的正确语法是什么:
array = ['a','b','c','d']
<?php
if element = 'a' or 'b' or 'c' or 'd':
echo something
?>
Run Code Online (Sandbox Code Playgroud)
当你的数组中有更多的值时...类似于:
array = ['a','b','c','d','e','f','g']
<?php
if element = one of the values from the array:
echo something
?>
Run Code Online (Sandbox Code Playgroud)
只需使用in_array():
if (in_array($element, array('a','b','c','d'))) {
// The value of $element is a, b, c, or d
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
109 次 |
| 最近记录: |