title: php find max value for both positive and negative value in array
body: <p>I have an array i want to find max value for both positive and negative value.
   The expected result would be -13.2 and 7.8</p>
  
  <pre><code>$array = array
  (
      [0] =&gt; -13.2
      [1] =&gt; -14.5
      [2] =&gt; -14.3
      [3] =&gt; -13.7
      [4] =&gt; -13.8
      [5] =&gt; -14.6
      [6] =&gt; 6.4
      [7] =&gt; 6.9
      [8] =&gt; 7.2
      [9] =&gt; 6.9
      [10] =&gt; 7.8
      [11] =&gt; 6.9
      [12] =&gt; 6.3
      [13] =&gt; 7.2
      [14] =&gt; 6.9
      [15] =&gt; 6.8
  )
  
  $maxrl='';
  for($i=1,$j=0;$i&lt;=count($array);$i++,$j++)
      {
          if($maxr &lt;= $array[$j])
              {
                  if(($maxr &lt; $array[$j]) &amp;&amp; ($maxrl != ''))
                      {
                          $maxrl='';
                          $maxrl.="L".$k.",";
                      }
                  else
                      {
                          $maxrl.="L".$k.",";
                      }
                  $maxr = $max_array[$j];
  
              }
          $k++;
      }
  echo "&lt;tr&gt;&lt;td &gt;'.$maxr.'&lt;/td&gt;&lt;td&gt;'.substr($maxrl,0,-1).'&lt;/td&gt;&lt;&gt;/tr&gt;";
  </code></pre>