This forum covers all minor versions of PHP 7
-
Administrator
- Site Admin
- Posts: 1725
- Joined: Thu Mar 22, 2018 10:19 am
Post
by Administrator » Fri Aug 24, 2018 10:37 am
You can get the odd and even number by using the modulus operator and comparing with 1 or 0 as shown
Code: Select all
if (($a % 2) == 1)
/* ODD */
if (($a % 2) == 0)
/* EVEN */