title: Calculate at least 3 minimum and maximum numbers from array
body: <p>Code</p>
  
  <pre><code>&lt;?php
  
      $array = array("1", "2", "3", "4", "5", "6", "7", "8", "100");
      $max = $temp = 0;
      $min = $temp = 0;
  
      //This loop is to get max and min value from array
      for ($i = 0 ; $i &lt; count($array); $i++) {
  
          if ($i == 0) {
              $max = $temp = $array[$i];
          }
  
          if ($i &gt; 0) {
              if ($array[$i] &gt; $temp) {
                  $max = $array[$i];
              }
          }
  
          if ($i == 0) {
              $min = $temp = $array[$i];
          }
  
          if ($i &lt; 0) {
              if ($array[$i] &lt; $temp) {
                  $min = $array[$i];
              }
          }
  
      }
  
      echo "Max Number = $max &lt;br&gt;";
      echo "Min Number = $min";
  
  
  ?&gt;
  </code></pre>
  
  <p>The above code only calculates one minimum and one maximum number from the array.  I need it to calculate 3 maximum and 3 minimum numbers.</p>
  
  <p>I can't use pre-made functions and can't use more than one for loop so kindly suggest me customization within the above code.</p>