note 92507 deleted from language.operators.comparison by danbrown

From: Date: Mon, 27 Jul 2009 21:35:36 +0000
Subject: note 92507 deleted from language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158797@lists.php.net to get a copy of this message
Note Submitter: nate at mt2009 dot com ---- @Anonymous: any time you start copy/pasting things like whether to mark each individual checkbox as checked, you should really be looping over an array and only checking that condition once. There is no reason why you should ever have checked="checked" in your code more than once for options of the same list. Example: <? $gender = 'f'; ?> <form> <? foreach (array( 'm' => 'Male', 'f' => 'Female' ) as $value => $label): ?> <input type="radio" name="gender" value="<?= $value; ?>"<?= $gender == $value ? ' checked="checked"' : ''; ?>> <?= $label ?> <? endforeach; ?> </form>

« previous php.notes (#158797) next »