run code in 150+ php & hhvm versions
Bugs & Features
<?php $regions = [ 'int' => 1, 'nl' => 2, 'be' => 4, 'us' => 8, 'as' => 16, 'za' => 32, ]; for ($i = 0; ++$i < 1 << count($regions); array_walk($regions, function ($x, $region) use (&$list, $i) { if (!($i & $x)) return; if (isset($list[$region])) $list[$region] .= ",$i"; else $list[$region] = $i; })); var_dump($list); unset($list); foreach ($regions as $region => $x) for ($i = $x; end($regions) * 2 - $i > 0; ++$i%$x?:$i+=$x){var_dump($i, $x, end($regions) * 2 - $i); if (isset($list[$region])) $list[$region] .= ",$i"; else $list[$region] = $i;} var_dump($list);
Output for 5.4.0 - 5.6.22, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0RC4
array(6) { ["int"]=> string(90) "1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63" ["nl"]=> string(91) "2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63" ["be"]=> string(91) "4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63" ["us"]=> string(93) "8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63" ["as"]=> string(95) "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63" ["za"]=> string(95) "32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63" } int(1) int(1) int(63) int(3) int(1) int(61) int(5) int(1) int(59) int(7) int(1) int(57) int(9) int(1) int(55) int(11) int(1) int(53) int(13) int(1) int(51) int(15) int(1) int(49) int(17) int(1) int(47) int(19) int(1) int(45) int(21) int(1) int(43) int(23) int(1) int(41) int(25) int(1) int(39) int(27) int(1) int(37) int(29) int(1) int(35) int(31) int(1) int(33) int(33) int(1) int(31) int(35) int(1) int(29) int(37) int(1) int(27) int(39) int(1) int(25) int(41) int(1) int(23) int(43) int(1) int(21) int(45) int(1) int(19) int(47) int(1) int(17) int(49) int(1) int(15) int(51) int(1) int(13) int(53) int(1) int(11) int(55) int(1) int(9) int(57) int(1) int(7) int(59) int(1) int(5) int(61) int(1) int(3) int(63) int(1) int(1) int(2) int(2) int(62) int(3) int(2) int(61) int(6) int(2) int(58) int(7) int(2) int(57) int(10) int(2) int(54) int(11) int(2) int(53) int(14) int(2) int(50) int(15) int(2) int(49) int(18) int(2) int(46) int(19) int(2) int(45) int(22) int(2) int(42) int(23) int(2) int(41) int(26) int(2) int(38) int(27) int(2) int(37) int(30) int(2) int(34) int(31) int(2) int(33) int(34) int(2) int(30) int(35) int(2) int(29) int(38) int(2) int(26) int(39) int(2) int(25) int(42) int(2) int(22) int(43) int(2) int(21) int(46) int(2) int(18) int(47) int(2) int(17) int(50) int(2) int(14) int(51) int(2) int(13) int(54) int(2) int(10) int(55) int(2) int(9) int(58) int(2) int(6) int(59) int(2) int(5) int(62) int(2) int(2) int(63) int(2) int(1) int(4) int(4) int(60) int(5) int(4) int(59) int(6) int(4) int(58) int(7) int(4) int(57) int(12) int(4) int(52) int(13) int(4) int(51) int(14) int(4) int(50) int(15) int(4) int(49) int(20) int(4) int(44) int(21) int(4) int(43) int(22) int(4) int(42) int(23) int(4) int(41) int(28) int(4) int(36) int(29) int(4) int(35) int(30) int(4) int(34) int(31) int(4) int(33) int(36) int(4) int(28) int(37) int(4) int(27) int(38) int(4) int(26) int(39) int(4) int(25) int(44) int(4) int(20) int(45) int(4) int(19) int(46) int(4) int(18) int(47) int(4) int(17) int(52) int(4) int(12) int(53) int(4) int(11) int(54) int(4) int(10) int(55) int(4) int(9) int(60) int(4) int(4) int(61) int(4) int(3) int(62) int(4) int(2) int(63) int(4) int(1) int(8) int(8) int(56) int(9) int(8) int(55) int(10) int(8) int(54) int(11) int(8) int(53) int(12) int(8) int(52) int(13) int(8) int(51) int(14) int(8) int(50) int(15) int(8) int(49) int(24) int(8) int(40) int(25) int(8) int(39) int(26) int(8) int(38) int(27) int(8) int(37) int(28) int(8) int(36) int(29) int(8) int(35) int(30) int(8) int(34) int(31) int(8) int(33) int(40) int(8) int(24) int(41) int(8) int(23) int(42) int(8) int(22) int(43) int(8) int(21) int(44) int(8) int(20) int(45) int(8) int(19) int(46) int(8) int(18) int(47) int(8) int(17) int(56) int(8) int(8) int(57) int(8) int(7) int(58) int(8) int(6) int(59) int(8) int(5) int(60) int(8) int(4) int(61) int(8) int(3) int(62) int(8) int(2) int(63) int(8) int(1) int(16) int(16) int(48) int(17) int(16) int(47) int(18) int(16) int(46) int(19) int(16) int(45) int(20) int(16) int(44) int(21) int(16) int(43) int(22) int(16) int(42) int(23) int(16) int(41) int(24) int(16) int(40) int(25) int(16) int(39) int(26) int(16) int(38) int(27) int(16) int(37) int(28) int(16) int(36) int(29) int(16) int(35) int(30) int(16) int(34) int(31) int(16) int(33) int(48) int(16) int(16) int(49) int(16) int(15) int(50) int(16) int(14) int(51) int(16) int(13) int(52) int(16) int(12) int(53) int(16) int(11) int(54) int(16) int(10) int(55) int(16) int(9) int(56) int(16) int(8) int(57) int(16) int(7) int(58) int(16) int(6) int(59) int(16) int(5) int(60) int(16) int(4) int(61) int(16) int(3) int(62) int(16) int(2) int(63) int(16) int(1) int(32) int(32) int(32) int(33) int(32) int(31) int(34) int(32) int(30) int(35) int(32) int(29) int(36) int(32) int(28) int(37) int(32) int(27) int(38) int(32) int(26) int(39) int(32) int(25) int(40) int(32) int(24) int(41) int(32) int(23) int(42) int(32) int(22) int(43) int(32) int(21) int(44) int(32) int(20) int(45) int(32) int(19) int(46) int(32) int(18) int(47) int(32) int(17) int(48) int(32) int(16) int(49) int(32) int(15) int(50) int(32) int(14) int(51) int(32) int(13) int(52) int(32) int(12) int(53) int(32) int(11) int(54) int(32) int(10) int(55) int(32) int(9) int(56) int(32) int(8) int(57) int(32) int(7) int(58) int(32) int(6) int(59) int(32) int(5) int(60) int(32) int(4) int(61) int(32) int(3) int(62) int(32) int(2) int(63) int(32) int(1) array(6) { ["int"]=> string(90) "1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63" ["nl"]=> string(91) "2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63" ["be"]=> string(91) "4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31,36,37,38,39,44,45,46,47,52,53,54,55,60,61,62,63" ["us"]=> string(93) "8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31,40,41,42,43,44,45,46,47,56,57,58,59,60,61,62,63" ["as"]=> string(95) "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63" ["za"]=> string(95) "32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63" }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/tG3RC on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/tG3RC on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/tG3RC on line 3
Process exited with code 255.