Re: filtering out array values
| From: | Merlin | Date: | Tue, 02 Nov 2004 18:25:09 +0000 |
| Subject: | Re: filtering out array values | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200945@lists.php.net to get a copy of this message | ||
Jason Wong wrote:
On Tuesday 02 November 2004 13:32, Merlin wrote:This did not work. Here is how I solved it: $key = array_search($ob_values[$h], $object); if ($key !== false) printf ("<option value = \"%s\"%s>%s</option>\n", $ob_values[$h],$isselected,$ob_options[$h]); MerlinI am retrieving some values out of the db and would only like to show those available inside a drop down field. Now I do have 2 arrays which fill the drop down field and one array with the values which should only show up. Example: $objects_available = array(3,5,7); $ob_options = array( 'all available', 'accomodations', 'internet access', 'tour operators', 'restaurants' , 'pubs', 'clubs', 'museums', 'secret spots', 'hotels at the airport'); $ob_values = array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); Has anybody an idea how to filter just the ones out which are inside the objects available array? I am sure this is possible without any if statements, but just cant come up with a clear programming solution.Assuming that '0' corresponds to 'all available', '1' to 'accomodations' etc, then: foreach ($objects_available as $key) {echo $ob_options[$key];}