[英]in_array() -- What am I doing wrong?
I'm banging my head against the wall here.我在这里用头撞墙。
I have some simple code that goes something like this (I've simplified it greatly for simplicity's sake):我有一些类似这样的简单代码(为了简单起见,我已经大大简化了它):
$myValue = 1;
$myArray[0] = 2;
$myArray[1] = 3;
$myArray[2] = 1;
if(in_array($myValue, $myArray, true)) {
do something;
}
else {
do something else;
}
I always get the 'else.'我总是得到“其他”。 Am I doing something wrong here?
我在这里做错了吗?
It will return "Yes".它将返回“是”。 Do & else are PHP keyword.
Do & else 是 PHP 关键字。 Echo Something.. It Will Come
回声某物..它会来
<?
$myValue = 1;
$myArray[0] = 2;
$myArray[1] = 3;
$myArray[2] = 1;
if(in_array($myValue, $myArray, true))
{
echo "Yes";
}
else
{
echo "No";
}
?>
Otherwise, if you use 'do' or 'else' keyword, Parse error: syntax error, unexpected '}', expecting while (T_WHILE) error will come.否则,如果使用 'do' 或 'else' 关键字,会出现解析错误:语法错误,意外的 '}',期望 while (T_WHILE) 错误。
For more info, read this http://www.w3schools.com/php/func_array_in_array.asp有关更多信息,请阅读此http://www.w3schools.com/php/func_array_in_array.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.