Re: If value is odd or not
| From: | Adam Zey | Date: | Mon, 05 Jun 2006 18:02:30 +0000 |
| Subject: | Re: If value is odd or not | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237424@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
On Fri, June 2, 2006 8:32 am, Jonas Rosling wrote:Let's make it even more compact and confusing :) echo "$variable is ".($variable % 2 ?'even':'odd')."<br />\n"; I'm not sure if you can nuke the whitespace in the modulus area or not. Regards, Adam Zey.is there any easy why to check if a value is odd or not?$parity = $variable % 2 ? 'even' : 'odd'; echo "$variable is $parity<br />\n";