我想计算偶数,奇数。如果有2个偶数,我只数1个偶数,如果有2个奇数,我只数1个奇数
<?php
$myarray = array(5,5,0,1,2,1,1,6,1);
for ($i = 0; $i < count($myarray); $i++) {
echo "Index ", $i, ", value ", $myarray[$i], ": ";
if ($myarray[$i] % 2 == 0) {
echo "even\n";
}
else {
echo "odd\n";
}
}
?>
输入=[5,5,0,1,2,1,1,6,1]
output = 5 :1(total(5) odd one),
1:2 (total(1) odd two)
慕工程0101907
www说
桃花长相依
MMMHUHU