note 102155 added to language.types.array

From: Date: Sun, 30 Jan 2011 09:05:19 +0000
Subject: note 102155 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-176508@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['rating'] = array("red", "blue", "olive"); $advanced_option['popularity'] = array("black", "off_white"); $advanced_option['age'] = array("on","sleep_mode"); 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/102155 Del: integrated -- https://master.php.net/note/delete/102155/integrated Del: useless -- https://master.php.net/note/delete/102155/useless Del: bad code -- https://master.php.net/note/delete/102155/bad+code Del: spam -- https://master.php.net/note/delete/102155/spam Del: non-english -- https://master.php.net/note/delete/102155/non-english Del: in docs -- https://master.php.net/note/delete/102155/in+docs Del: other reasons-- https://master.php.net/note/delete/102155 Reject -- https://master.php.net/note/reject/102155 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176508) next »