title: PHP Array to string conversion in multiple selected dropdown
body: <p>I have this function for show selected value in multiple dropdown: </p>
  
  <pre><code>function _is_dropdown_( $name,array $selected=null,$table ,$class,$required,$type_name,$type, $size )
  {
          $options = DB::fetch("SELECT name, id FROM " . $table . " WHERE ". $type_name ." = ? ORDER BY name",$type);
        //$options = array();
          /*** begin the select ***/
          $dropdown = '&lt;select name="'.$name.'" id="'.$name.'" class="'.$class.'" required = "'.$required.'" size="'.$size.'" multiple&gt;'."\n";
  
          /*** loop over the options ***/
          foreach($options as $key=&gt;$option )
          {
                  /*** assign a selected value ***/
                  $select = in_array( $option, $selected ) ? ' selected' : null;
  
                  /*** add each option to the dropdown ***/
                  $dropdown .= '&lt;option value="'.$key.'" '.$select.' &gt;'.$option.'&lt;/option&gt;'."\n";
          }
  
          /*** close the select ***/
          $dropdown .= '&lt;/select&gt;'."\n";
  
          /*** and return the completed dropdown ***/
          return $dropdown;
  }
  </code></pre>
  
  <p>for result:</p>
  
  <pre><code>$name = 'book_cover[]';
  $selected = json_decode($DB_QUERY[0]['book_cover'] , true);
  echo _is_dropdown_( $name,$selected ,NEWS_TYPE ,'contentgroup','required','book_type','4', '4' );
  </code></pre>
  
  <p>Now in result dropdown not show name of <code>option</code>:</p>
  
  <pre><code>&lt;select name="book_cover[]" class="contentgroup" required = "required" size="4" multiple&gt;
  &lt;option value="0"  &gt;Array&lt;/option&gt;
  &lt;option value="1"  &gt;Array&lt;/option&gt;
  &lt;option value="2"  &gt;Array&lt;/option&gt;
  &lt;option value="3"  &gt;Array&lt;/option&gt;
  &lt;option value="4"  &gt;Array&lt;/option&gt;
  &lt;option value="5"  &gt;Array&lt;/option&gt;
  &lt;option value="6"  &gt;Array&lt;/option&gt;
  &lt;option value="7"  &gt;Array&lt;/option&gt;
  &lt;option value="8"  &gt;Array&lt;/option&gt;
  &lt;option value="9"  &gt;Array&lt;/option&gt;
  &lt;option value="10"  &gt;Array&lt;/option&gt;
  &lt;option value="11"  &gt;Array&lt;/option&gt;
  &lt;option value="12"  &gt;Array&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>And show this error :</p>
  
  <pre><code>[2015-09-09 08:28:06] [E_NOTICE] [8] Array to string conversion in C:\xampp\htdocs\cms\class\functions.php:1032 
  </code></pre>
  
  <p><strong>EDIT</strong>: i <code>print_r</code> $options:</p>
  
  <pre><code>(
      [0] =&gt; Array
          (
              [name] =&gt; test
          )
  
      [1] =&gt; Array
          (
              [name] =&gt; test2
          )
  
      [2] =&gt; Array
          (
              [name] =&gt; test3
          )
  )
  </code></pre>
  
  <p><strong>EDIT 2</strong>: i change <code>$options</code> to manual array : <code>$options = array( 'test', 'test1', 'test2' );</code> this worked fine. now i need to convert <code>my db result</code> to this. </p>
  
  <p>how do fix this error ?!</p>