note 105181 deleted from function.is-numeric by thiago
| From: | thiago@php.net | Date: | Tue, 02 Aug 2011 12:10:03 +0000 |
| Subject: | note 105181 deleted from function.is-numeric by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182098@lists.php.net to get a copy of this message | ||
Note Submitter: ivanspires at cox dot net
----
This code will allow you to use the is_numeric function and the modulus conditional operator to find
even numbers. It's a bit large but will do the trick.
<?php
$w = 2;
$x = 3;
$y = 4;
$z = 5;
echo is_numeric($w) & (($w % 2) == 0) ? "The number $w is even<br/>" : "The
number $w is not even<br/>";
echo is_numeric($x) & (($x % 2) == 0) ? "The number $x is even<br/>" : "The
number $x is not even<br/>";
echo is_numeric($y) & (($y % 2) == 0) ? "The number $y is even<br/>" : "The
number $y is not even<br/>";
echo is_numeric($z) & (($z % 2) == 0) ? "The number $z is even<br/>" : "The
number $z is not even<br/>";
?>