gli Posted June 7, 2008 Share Posted June 7, 2008 Hi! I want to make 'if number is pair number, then execute command' , i dont know the pair number thing. Sorry for my bad English. And i dont know if 'pair number' is right in the English, so i will explain, i mean pair number like 2,4,6,8,10,12,14 etc. all numbers which can divide with 2 <?php $number = 4; if ($number == ?PAIRNUMBER?) { echo "this is a pair number"; } ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 7, 2008 Share Posted June 7, 2008 Ah. They are called even numbers. (The other ones are odd numbers like 1, 3, 5, 7.) You can do: $number = 4; if ($number % 2 == 0) { echo "It's even!"; } else { echo "Odd."; } Quote Link to comment Share on other sites More sharing options...
gli Posted June 7, 2008 Author Share Posted June 7, 2008 Thanks for English lesson and the code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.