title: Get selected value from dropdown menu, from an array?
body: <p>I feel like I am really missing something here. I did some manual customizations on a short (wordpress) script and try to set a <code>&lt;select&gt;&lt;option&gt;</code> to "selected" if it has been selected. In order to accomplish this, I tried to find out if the <code>$term-&gt;id = similar</code> to the selected option value (which is an ID as well). All good so far, but I cannot seem to get the submitted <code>&lt;select&gt;&lt;option&gt;</code>. All it says is 'array'.</p>
  
  <p>Below is my script. Does anyone see what I am doing wrong here? To be clear, it seems to be all about the <code>$_GET["listing_cat"]</code> here. Also when i try to print the <code>$_GET["listing_cat"]</code> within the <code>foreach</code> all it outputs is 'array'.</p>
  
  <pre><code>&lt;form method="get" action="&lt;?php echo trailingslashit( home_url() ); ?&gt;" class="custsearch"&gt;
  &lt;select name="listing_cat[]"&gt;
  &lt;option value="1" disabled="disabled" &lt;?php if(!count($_GET)&gt;0 || !$_GET["listing_cat"] ){ echo 'selected="selected"';} ?&gt;&gt;Pls choose&lt;/option&gt;
          &lt;?php
          $cat_args = array(
          'orderby'           =&gt; 'id', 
          'parent'        =&gt; 0,
          'hide_empty'    =&gt; false           
      );
          $terms = get_terms('listing_category', $cat_args );
          foreach ($terms as $term) {
              printf( '&lt;option class="level-0" value="' . $term-&gt;term_id .'"');
              if($_GET["listing_cat"] == $term-&gt;term_id) { echo 'selected="selected"'; }
              printf( '&gt;%s&lt;/option&gt;', $term-&gt;slug, $term-&gt;name );
          }
  
          ?&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>