note 105193 deleted from function.is-numeric by thiago

From: Date: Tue, 02 Aug 2011 14:39:33 +0000
Subject: note 105193 deleted from function.is-numeric by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182104@lists.php.net to get a copy of this message
Note Submitter: Ivan Spires ---- While this is quite bulky, this code will let you use the is_numeric and a conditional operator to find even numbers. <?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/>"; ?>

« previous php.notes (#182104) next »