RE: [PHP] Question: Simpler loop

From: Date: Fri, 22 Oct 2004 15:45:37 +0000
Subject: RE: [PHP] Question: Simpler loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200093@lists.php.net to get a copy of this message
Yep, Mike's solution is simpler. It's getting late on Friday and the brain is starting to slow down. (That's my excuse anyway...) [snip] > > > > Is there a simpler way / shorter way to check > > conditions to do this ? > > So, the entry is valid only if all three are non-blank? > > In which case: > > if ($skill!='' && $skys[$key]!='' && $slus[$key] > !='') > { > // row is valid -- do stuff > } > else > { > // entry has at least one value blank -- issue error > } > > If you prefer to have the error path come first, simply apply deMorgan's > laws to the Boolean expression, to get: > > if ($skills=='' || $skys[$key]=='' || $slus[$key]=='') > { > // entry has at least one value blank -- issue error > } > else > { > // row is valid -- do stuff > } > > Cheers! > > Mike > [snip]

« previous php.general (#200093) next »