note 102156 added to language.types.array

From: Date: Sun, 30 Jan 2011 09:08:01 +0000
Subject: note 102156 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-176509@lists.php.net to get a copy of this message
Multidimensional arrays work great for checking search options if they exist in a $_GET string. The following saved me a lot of time. <?php $advanced_option['color'] = array("red", "blue", "green"); $advanced_option['state'] = array("new", "broken"); $advanced_option['state'] = array("on","off"); foreach($advanced_option as $y => $advanced_option[$y]) { // HERE WARE ARE GOING INTO EACH ARRAY'S VALUES/ITEMS $sub_array = $advanced_option[$y]; foreach($sub_array as $z => $sub_array[$z]) { // IF THE SEARCH OPTI0N EXISTS IN THE GET STRING, SET AN ARRAY NAMED AFTER THAT VALUE TO BE CHECKED (FOR CHECKBOXES & RADIOBUTTONS) if ($_GET[$y] == $advanced_option[$y][$z]) { $checked[$advanced_option[$y][$z]] = "checked"; } } } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 71.197.204.162 ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit -- https://master.php.net/note/edit/102156 Del: integrated -- https://master.php.net/note/delete/102156/integrated Del: useless -- https://master.php.net/note/delete/102156/useless Del: bad code -- https://master.php.net/note/delete/102156/bad+code Del: spam -- https://master.php.net/note/delete/102156/spam Del: non-english -- https://master.php.net/note/delete/102156/non-english Del: in docs -- https://master.php.net/note/delete/102156/in+docs Del: other reasons-- https://master.php.net/note/delete/102156 Reject -- https://master.php.net/note/reject/102156 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176509) next »