3v4l.org

run code in 300+ PHP versions simultaneously
<?php // arrB to not get changes reflected once we sort $arrB = $array = [4, 1, 5, 52, 75, 52, 24]; function findMinDiff($arr) { $n = count($arr); // Initialize difference // as infinite $diff = PHP_INT_MAX; // Find the min diff by comparing // difference of all possible // pairs in given array $two_values = []; for ($i = 0; $i < $n - 1; $i++) { for ($j = $i + 1; $j < $n; $j++) { if (abs($arr[$i] - $arr[$j]) < $diff) { $diff = abs($arr[$i] - $arr[$j]); $two_values['values'] = [$arr[$i], $arr[$j]]; $two_values['keys'] = [$i, $j]; $two_values['diff'] = $diff; } } } // Return min diff return $two_values; } print_r(findMinDiff($array));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [values] => Array ( [0] => 52 [1] => 52 ) [keys] => Array ( [0] => 3 [1] => 5 ) [diff] => 0 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
73.42 ms | 401 KiB | 8 Q