note 102155 deleted from language.types.array by thiago

From: Date: Mon, 31 Jan 2011 04:06:53 +0000
Subject: note 102155 deleted from language.types.array by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176517@lists.php.net to get a copy of this message
Note Submitter: falkon303 at gmail dot com ---- 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"; } } } ?>

« previous php.notes (#176517) next »