php - print even and (sorted) odd numbers of an array
<p>I have an array given below</p>

<pre><code>$array = array(50,51,52,53,54,55,56,57,58,59);
</code></pre>

<p>I am trying to print the values of array while even numbers will remain in same order and the odd numbers are sorted i.e. 59,57,55,53,51</p>

<p>The output should be like </p>

<pre><code>50,59,52,57,54,55,56,53,58,51
</code></pre>

<p>I've separated the even and odd numbers in two diff variables. how should i proceed further ?</p>

<p>here is my code </p>

<pre><code>  $even= "";
  $odd= "";

for($i=50;$i&lt;=59;$i++)
{
    if($i%2==0)
    {
        $even.=$i.",";
    }else $odd.=$i.","; 
}   
echo $even.$odd; 
</code></pre>