note 106193 deleted from function.ldap-search by danbrown
| From: | danbrown@php.net | Date: | Tue, 18 Oct 2011 14:46:49 +0000 |
| Subject: | note 106193 deleted from function.ldap-search by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183969@lists.php.net to get a copy of this message | ||
Note Submitter: Cernescu Florian
----
<?php
function numara($x,$o)
{
$contor=0;
while($x>0)
{
$r=$x%10;
if($r%2==$o)
$contor++;
$x=$x/10;
}
return $contor;
}
$a=1234;
$b=1234;
$a1=numara($a,0);
$b1=numara($b,1);
echo "cifre pare: ".$a1;
echo "cifre impare: ".$b1;
?>
This program should show me the number of odd and even numbers in 1234; the problem is it adds at
the number of even numbers 324. I just can't find anything wrong with it... any ideeas? thanks
in advance!