You are here: Re: problem with multiple conditions « PHP Programming Language « IT news, forums, messages
Re: problem with multiple conditions

Posted by Jerry Stuckle on 11/27/06 13:54

Michael Fesser wrote:
> .oO(greedo@starschiffchen.de)
>
>
>>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.
>
>
> Works here on PHP 5.2. What version do you use?
>
>
>>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.
>
>
> In this case the second condition will always be FALSE.
> It should be
>
> if (($zee[0] & 1) && !($zee[1] & 1)) {
> ...
> }
>
> Micha

No, it doesn't work here in PHP 5.2. It looks like it does in your case
maybe because you aren't displaying your errors?

Additionally, his test is perfectly correct. ($x % 2) will be zero for
even numbers and 1 for odd numbers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация