本文介绍了多个条件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,请耐心等待我,我真的不太了解

关于php编程,从代码中可以看出很明显

片段我要发帖。但我需要解决这个问题,而且我不能找到我需要的信息(或者我可能听不懂)。所以这里的东西是:
这个东西:


我所拥有的是一系列整数,我需要那些数字

在奇数和偶数之间交替。例如:123456789。为此目的我

这里有这个东西:


settype($ zee," string");

if(($ zee [0]%2!= 0)&&($ zee [1]%2 == 0))

{

echo $ zee。 < br />" ;;


}


准确一点:我想让$ zee回显,如果第一个数字是

奇数,第二个数字是偶数。


现在,这不起作用,因为显然第二个条件是

永远不会是真的。我不明白为什么。因为如果我改变了==在第二个

条件下!= (也就是说我希望两个数字都是奇数),然后

它运行正常!有人可以帮我解决这个问题吗?


PS:

条件是这样的:

if(($ zee [0]& 1)&&($ zee [1]& 0))

完全相同的事情发生:它适用于两个奇怪的条件,但不是

有一个奇数,一个偶数。

Hi, first of all, please bear with me, I don''t really know a great deal
about php programming, as will be painfully obvious from the code
snippet I''m gonna post. But I need this problem solved, and I can''t
find the information I need (or maybe I can''t understand it). So here''s
the thing:

What I have is a range of integers, and I need those whose digits
alternate between odd and even. Example: 123456789. For that purpose I
have this thingy here:

settype($zee, "string");
if (($zee[0] % 2 != 0) && ($zee[1] % 2 == 0))
{
echo $zee . "<br />";

}

Just to be precise: I want to have $zee echoed, if the first digit is
odd and the second is even.

Now, this doesn''t work, because apparently the second condition is
never true. I don''t get why. Because if I change the "==" in the second
condition to "!=" (that is to say I want both digits to be odd), then
it works fine! Can someone help me fix this?

PS:
When the conditions are put like this:
if (($zee[0] & 1) && ($zee[1] & 0))
the exact same thing happens: it works with two odd conditions, but not
with one odd, one even.

推荐答案




这篇关于多个条件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 22:42