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"; } ?> Link to comment https://forums.phpfreaks.com/topic/109155-solved-if-number-is-pair-number/ 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."; } Link to comment https://forums.phpfreaks.com/topic/109155-solved-if-number-is-pair-number/#findComment-559927 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. Link to comment https://forums.phpfreaks.com/topic/109155-solved-if-number-is-pair-number/#findComment-559930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.