note 105629 deleted from language.operators.arithmetic by danbrown

From: Date: Fri, 02 Sep 2011 15:17:21 +0000
Subject: note 105629 deleted from language.operators.arithmetic by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182902@lists.php.net to get a copy of this message
Note Submitter: Stuart ---- Simpler and less dependent on an artifact of the PHP that could conceivably change. <?php for ($x=0; $x<14; $x++) { if ($x % 3 === 0) { // if $x divisable by 3 remainder == 0 echo $x . ' is divisible by 3 <br>'; } } ?> Actual output: 0 is divisible by 3 3 is divisible by 3 6 is divisible by 3 9 is divisible by 3 12 is divisible by 3 Obviously this will not work for floats but they require more care as in an arbitrary case one can never be sure they divide exactly.

« previous php.notes (#182902) next »