note 87618 modified in control-structures.switch by danbrown

From: Date: Fri, 12 Dec 2008 22:04:38 +0000
Subject: note 87618 modified in control-structures.switch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148106@lists.php.net to get a copy of this message
in case of multiple switch is needed this may also work. <?php switch (true) { case ($full_datum_auto==NULL and $full_datum_rev==NULL): $datemessage = "both NULL"; break; case ($full_datum_auto==NULL and $full_datum_rev!=NULL): $datemessage = "REVISED"; break; case ($full_datum_auto!=NULL and $full_datum_rev==NULL): $datemessage = "AUTO"; break; case ($full_datum_auto!=NULL and $full_datum_rev!=NULL): if ($full_datum_rev > $full_datum_auto) { $datemessage = "AUTO and REVISED, but REVISED is bigger"; } elseif ($full_datum_rev == $full_datum_auto) { $datemessage = "both equal"; } else { $datemessage = "AUTO and REVISED, but AUTO is bigger"; } break; default : $datemessage = "default filter is reached"; break; } ?> --was-- in case of multiple switch is needed this may also work. switch (true) { case ($full_datum_auto==NULL and $full_datum_rev==NULL): $datemessage = "both NULL"; break; case ($full_datum_auto==NULL and $full_datum_rev!=NULL): $datemessage = "REVISED"; break; case ($full_datum_auto!=NULL and $full_datum_rev==NULL): $datemessage = "AUTO"; break; case ($full_datum_auto!=NULL and $full_datum_rev!=NULL): if ($full_datum_rev > $full_datum_auto) { $datemessage = "AUTO and REVISED, but REVISED is bigger"; } elseif ($full_datum_rev == $full_datum_auto) { $datemessage = "both equal"; } else { $datemessage = "AUTO and REVISED, but AUTO is bigger"; } break; default : $datemessage = "default filter is reached"; break; } http://php.net/manual/en/control-structures.switch.php

« previous php.notes (#148106) next »