Compare 2 arrays in PHP with checkbox checked (keep stucture)
<p>I need to compare 2 arrays one from database with available cloth Sizes 
and a default Size</p>

<pre><code>$sizedefault = array('s','m','l','xl','xxl','xxxl','xxxxl','xxxxxl'); // Default Sizes
$sizeavailable = explode(',',$pd_size);    // Available Sizes (db) s,m,l,xl

$available = array_diff($sizedefault , $sizeavailable );
$notavailable = array_intersect($sizeavailable , $sizedefault);
$output = "";
foreach ($notavailable as $value){
$output .= "&lt;input type=\"checkbox\" name=\"size[]\" id=\"$value\" value=\"$value\" checked=\"checked\"/&gt;&lt;label for=\"$value\"&gt;".$value."&lt;/label&gt;";

}
foreach($available as $value){
$output .= "&lt;input type=\"checkbox\" name=\"size[]\" id=\"$value\" value=\"$value\" /&gt;&lt;label for=\"$value\"&gt;".$value."&lt;/label&gt;";
}
</code></pre>

<p>that works so far but, the output is not sorted after i check eg: "xxxxl" and submit/request</p>

<p>i get this result:    (x) = checked</p>

<blockquote>
  <p>s(x) m(x) l(x) xl(x) xxxxl(x) xxxxxl() xxl()</p>
</blockquote>

<p>how can i keep them sorted as <code>$sizedefault</code>?</p>

<blockquote>
  <p>s(x) m(x) l(x) xl(x) xxl() xxxxl(x) xxxxxl()</p>
</blockquote>
