Multiple selections in metabox
<p>I want to make the user the ability to chose several posts that related to the post that his about the publish, so that post will shown at the bottom of the post itself.
So I created a metabox with multiple selctions.
Now I have two problems:
1)Save his chooses as array of options. I've manage to do it only with this code:</p>

<pre><code>update_post_meta( $post_id, 'related-posts', array_map( 'strip_tags', $_POST['related-posts']) );
</code></pre>

<p>The thing is that it makes array-of-array:</p>

<pre><code>array (size=1)
  0 =&gt; 
    array (size=8)
      0 =&gt; string '38262' (length=5)
      1 =&gt; string '38257' (length=5)
      2 =&gt; string '38247' (length=5)
      3 =&gt; string '38217' (length=5)
      4 =&gt; string '38228' (length=5)
      5 =&gt; string '38229' (length=5)
      6 =&gt; string '38211' (length=5)
      7 =&gt; string '38198' (length=5)
</code></pre>

<p>Is this the right way of doing it? there's no better solution to make it only one-dimensional array? (I don't want to use implode method).</p>

<p>2)When the choises were saved, they need to be highlighted, so I've tried this:</p>

<pre><code>$array_posts = get_posts($args); ?&gt;
&lt;form action="" method="post" name="related-post-form"&gt; 
    &lt;select name='related-posts[]' multiple='multiple' size='30'&gt;
        &lt;?php foreach($array_posts as $post): setup_postdata($post); ?&gt;
        &lt;option value="&lt;?php echo $post-&gt;ID; ?&gt;" &lt;?php if ($_POST['related-posts'] == $post-&gt;ID ) echo ' selected'; ?&gt;&gt;&lt;?php the_title(); ?&gt;&lt;/option&gt;
      &lt;?php endforeach; ?&gt;
    &lt;/select&gt;
&lt;/form&gt;
</code></pre>

<p>Doesn't work.</p>

<p>Any help will be appreciate.. Thanks!</p>