Re: easier than switch

From: Date: Mon, 04 Aug 2003 22:43:15 +0000
Subject: Re: easier than switch
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-158202@lists.php.net to get a copy of this message
skate wrote:
okay, so i know there's an easy way to do this, and i've seen it done, sure of it. so please forgive the stupidity of my question, i don't even know where to begin to look in the archives either... i have several forms on one page, they all submit a different variable, i then want to set one variable depending on that... okay, now i'm confusing myself, lets try explain it with some code... <? if(isset($_POST)) { $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] || $_POST['words'] || $_POST['chat']; } ?> obviously this doesn't work. but i wanna set $type depending on which $_POST variable was sent. only one of these will ever be sent. rather than doing a big ass switch statement, is there no way i can get this into one line? i hope this isn't too confusing...
If you're really sure only one will be sent: $type = $_POST['news'] . $_POST['dreams'] . $_POST['storys'] . $_POST['words'] . $_POST['chat']; will achieve what you're looking for. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com

« previous php.general (#158202) next »