quick links

Print only odd number, only even number, Check given number is odd or even

Print only odd number

<?php
for($i=1; $i<=25; $i++) {
if($i%2 == 0) {
$even[] = $i;
} else {
$odd[] = $i;
}
}
echo implode(",",$odd);
?>

OUT PUT: 1,3,5,7,9,11,13,15,17,19,21,23,25

Print only even number

<?php
for($i=1; $i<=25; $i++) {
if($i%2 == 0) {
$even1[] = $i;
} else {
$odd1[] = $i;
}
}
echo implode(",",$even1);
?>

OUT PUT: 2,4,6,8,10,12,14,16,18,20,22,24

Check given number is odd or even

<?php
$i = 25;
if($i%2 == 0) {
echo $i.' is even number';
} else {
echo $i.' is odd number';
}
?>

OUT PUT: 25 is odd number

 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK