![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Is there a function which returns something to say if a number is divisible by two / even or odd?!?!?]]
like: function foo($number) { if (number_divisble_by_two($number)) { //stuff } else { //different stuff } } or function fooVersion2point0($number) { if (even_number($number)) { //stuff } else //number is odd { //different stuff } }
__________________
Don't listen to me, I don't know what I'm on about... Last edited by man_im_bored; 01-25-04 at 23:29.. |
| Sponsored links |
|
|
|
#2
|
||||
|
||||
|
Solution:
(I've figured it out, so I'm posting it for the benefit of otheres...) function oddoreven($number) { if ($number % 2 == 1) { return "the number is odd"; } else { return "the number is even";} } % = a mod
__________________
Don't listen to me, I don't know what I'm on about... |
|
#3
|
||||
|
||||
|
try the mod function.
__________________
"The American people will never knowingly adopt Socialism..." -Norman Thomas |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IIS on Win2k3 Server, getting some probs with php | goldfish | Software | 3 | 01-13-04 15:28 |
| PHP - fopen() and fwrite() | man_im_bored | Programming | 0 | 12-26-03 06:51 |