note 116283 deleted from language.operators.arithmetic by salathe

From: Date: Mon, 21 Sep 2020 14:58:14 +0000
Subject: note 116283 deleted from language.operators.arithmetic by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215401@lists.php.net to get a copy of this message
Note Submitter: Dominik Buechler ---- In addition to Jonathan's comment, there is a way simpler way to determine if an integer is even or not: <? $odd = $i % 2; ?> or <? $even = !($i % 2); ?> This works because a modulo division by 2 will always return either 0 or the rest 1. Since those are valid boolean values you can just invert them by adding a prefixed ! if wanted.

« previous php.notes (#215401) next »