Q php
Q php
- Started
- Last post
- 4 Responses
- OZute
Is there any way to sort even and odd integers with a conditional statement?
pseudo
if ($var == even) {
echo 'even';
}
else {
echo 'odd';
}
- stewart0
weeeekend... not a good time for odd questions.
- rabattski0
i don't know if there's a statement specifically made for that but easiest way is by dividing the integer by 2. if you have stuff behind the . it's not even else it is. obviously. :)
- fate_redux0
if (($var%2)==0) {
echo "even";
} else {
echo "odd";
}Courtesy my buddy Edward from Glasgow.
- fate_redux0
And it does just what rabattski described.