note 71048 added to language.variables

From: Date: Thu, 09 Nov 2006 16:29:42 +0000
Subject: note 71048 added to language.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-119561@lists.php.net to get a copy of this message
I had the issue of numerous HTML form checkboxes under separate groupings and not wanting to evaluate each checkbox individually. PHP's variable concatenation allowed me to vastly simplify this process by defining each checkbox grouping in a uniform name followed by incremental integer, then executing this code: <? $groups = array(27 => 'infants', 28 => 'toddlers', 41 => 'teens'); foreach ($groups as $count => $name) for ($i = 0; $i < $count; $i++) if (${$name . $i}) ${"total_" . $name} .= ${$name . $i} . ", "; ?> From here you can store $total_* variable(s) and retrieve them exploding on a comma delimiter. ---- Server IP: 66.163.161.117 Probable Submitter: 128.192.83.117 ---- Manual Page -- http://www.php.net/manual/en/language.variables.php Edit -- https://master.php.net/note/edit/71048 Del: integrated -- https://master.php.net/note/delete/71048/integrated Del: useless -- https://master.php.net/note/delete/71048/useless Del: bad code -- https://master.php.net/note/delete/71048/bad+code Del: spam -- https://master.php.net/note/delete/71048/spam Del: non-english -- https://master.php.net/note/delete/71048/non-english Del: in docs -- https://master.php.net/note/delete/71048/in+docs Del: other reasons-- https://master.php.net/note/delete/71048 Reject -- https://master.php.net/note/reject/71048 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119561) next »