3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function check($s1, $s2) { global $jdeg, $lmon; //var_dump($s1, $s2); $deg1 = $jdeg[$s1]; $deg2 = $jdeg[$s2]; $mon1 = $lmon[$deg1]; $mon2 = $lmon[$deg2]; if( ($deg1 == 270 || $deg2 == 270) || ($deg1 == 0 || $deg2 == 0) || ($deg1 == 90 || $deg2 == 90) || ($deg1 == 180 || $deg2 == 180) ) { if($deg1 == 270 || $deg1 == 0 || $deg1 == 90 || $deg1 == 180) { $ldeg1 = $deg1; $ldeg2 = $deg2; $lmon1 = $mon1; $lmon2 = $mon2; } else { $ldeg1 = $deg2; $ldeg2 = $deg1; $lmon1 = $mon2; $lmon2 = $mon1; } } else { $ldeg1 = $deg1; $ldeg2 = $deg2; $lmon1 = $mon1; $lmon2 = $mon2; } return array($ldeg1, $ldeg2, $lmon1, $lmon2); } function main() { global $lmon, $jdeg, $jung; $lmon = array(330 => 1, 0 => 2, 30 => 3, 60 => 4, 90 => 5, 120 => 6, 150 => 7, 180 => 8, 210 => 9, 240 => 10, 270 => 11, 300 => 12); $jdeg = array( 0 => "270", 1 => "300", 2 => "330", 3 => "0", 4 => "30", 5 => "60", 6 => "90", 7 => "120", 8 => "150", 9 => "180", 10 => "210", 11 => "240", 12 => "270", 13 => "300", 14 => "330", 15 => "0", 16 => "30", 17 => "60", 18 => "90", 19 => "120", 20 => "150", 21 => "180", 22 => "210", 23 => "240", 24 => "270", 25 => "300", 26 => "330", 27 => "0", 28 => "30", 29 => "60", 30 => "90", 31 => "120", 32 => "150", 33 => "180", 34 => "210", 35 => "240", 36 => "270", 37 => "300", 38 => "330", 39 => "0", 40 => "30", 41 => "60", 42 => "90", 43 => "120", 44 => "150", 45 => "180", 46 => "210", 47 => "240", 48 => "270", 49 => "300", 50 => "330", 51 => "0", 52 => "30", 53 => "60", 54 => "90", 55 => "120", 56 => "150", 57 => "180", 58 => "210", 59 => "240", 60 => "270", 61 => "300", 62 => "330", 63 => "0", 64 => "30", 65 => "60", 66 => "90", 67 => "120", 68 => "150", 69 => "180", 70 => "210", 71 => "240", 72 => "270", 73 => "300", 74 => "330", 75 => "0", 76 => "30", 77 => "60", 78 => "90", 79 => "120", 80 => "150", 81 => "180", 82 => "210", 83 => "240", 84 => "270", 85 => "300", 86 => "330", 87 => "0", 88 => "30", 89 => "60", 90 => "90", 91 => "120", 92 => "150", 93 => "180", 94 => "210", 95 => "240", 96 => "270", 97 => "300", 98 => "330", 99 => "0", 100 => "30", 101 => "60", 102 => "90", 103 => "120", 104 => "150"); $jung = array( 0 => "0", 1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5", 6 => "6", 7 => "7", 8 => "8", 9 => "9", 10 => "10", 11 => "11", 12 => "12", 13 => "13", 14 => "14", 15 => "15", 16 => "16", 17 => "17", 18 => "18", 19 => "19", 20 => "20", 21 => "21", 22 => "22", 23 => "23", 24 => "24", 25 => "-1", 26 => "25", 27 => "26", 28 => "27", 29 => "28", 30 => "29", 31 => "30", 32 => "31", 33 => "32", 34 => "33", 35 => "34", 36 => "35", 37 => "36", 38 => "37", 39 => "38", 40 => "39", 41 => "40", 42 => "41", 43 => "42", 44 => "43", 45 => "44", 46 => "45", 47 => "46", 48 => "47", 49 => "48", 50 => "49", 51 => "50", 52 => "51", 53 => "52", 54 => "53", 55 => "-1", 56 => "54", 57 => "55.56", 58 => "-1", 59 => "57.58", 60 => "-1", 61 => "59", 62 => "60", 63 => "61", 64 => "62", 65 => "63", 66 => "64", 67 => "65", 68 => "66", 69 => "67", 70 => "68", 71 => "69", 72 => "70", 73 => "71", 74 => "72", 75 => "73", 76 => "74", 77 => "75", 78 => "76", 79 => "77", 80 => "78", 81 => "79", 82 => "80", 83 => "81", 84 => "82", 85 => "83", 86 => "84", 87 => "85", 88 => "86", 89 => "87", 90 => "-1", 91 => "88", 92 => "89", 93 => "90", 94 => "91", 95 => "92", 96 => "93", 97 => "94", 98 => "95", 99 => "96", 100 => "97"); test(); } function test() { global $lmon, $jdeg, $jung; for($j=0; $j<1000; $j++) { for($i=0; $i<1000; $i++) { $r = $jung[$i]; if(preg_match("/\./", $r)) { $s = preg_split("/\./", $r); $s0 = $s[0]; $s1 = $s[1]; //var_dump($s); $r = check($s0, $s1); echo "[$j][$i] : $r[0], $r[1], $r[2], $r[3]\n"; } } } } main();
based on KFpAe