fork(1) download
  1. <?php
  2.  
  3. $khal = [100, 200, 101, 201];
  4. $mormont = array();
  5. $count = INF;
  6.  
  7. for($i = 0; $i < count($khal); $i++){
  8. for ($n = 0; $n < count($khal); $n++){
  9. if($i==$n){
  10. continue;
  11. }
  12.  
  13. $jorah = abs($khal[$i]-$khal[$n]);
  14.  
  15.  
  16. if($jorah < $count){
  17. $count = $jorah;
  18. $mormont[0]=$khal[$i];
  19. $mormont[1]=$khal[$n];
  20. }
  21. }
  22. }
  23.  
  24. var_dump ($mormont);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(2) {
  [0]=>
  int(100)
  [1]=>
  int(101)
}