fork download
  1. http://i...content-available-to-author-only...e.com/7MM3Y6<?php
  2. $arr = array (20, 1, 5, 10, 7, 16,-45,90,8,-77,88,77);
  3. $temp=array();
  4. for ($i = 0; $i < count($arr); $i++)
  5. {
  6. $diff=0;
  7. for ($j = $i+1; ($j < count($arr) && $i!=$j); $j++)
  8. {
  9. $diff=abs($arr[$i]-$arr[$j]);
  10. $temp[] = array($arr[$i], $arr[$j], $diff);
  11. }
  12. }
  13. usort($temp,
  14. function ($a, $b) { return $b[2] < $a[2]; });
  15. list($x,$y,$d) = $temp[0];
  16. echo "Related Values are $x and $y by $d";
  17. ?>
  18.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
http://i...content-available-to-author-only...e.com/7MM3Y6Related Values are 7 and 8 by 1