3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Tools{ /** * Recursive version of array_diff_assoc * Returns everything from $a that is not in $b or the other arguments * * @param $a The array to compare from * @param $b An array to compare against * @param ... More arrays to compare against * * @return An array with everything from $a that not in $b or the others */ public static function array_diff_assoc_recursive($a, $b){ // Get all of the "compare against" arrays $b = array_slice(func_get_args(), 1); // Initial return value $ret = array(); // Loop over the "to" array and compare with the others foreach($a as $key=>$val){ // We should compare type first $aType = gettype($val); // If it's an array, we recurse, otherwise we just compare with "===" $args = $aType === 'array' ? array($val) : true; // Let's see what we have to compare to foreach($b as $x){ // If the key doesn't exist or the type is different, // then it's different, and our work here is done if(!array_key_exists($key, $x) || $aType !== gettype($x[$key])){ $ret[$key] = $val; continue 2; } // If we are working with arrays, then we recurse if($aType === 'array'){ $args[] = $x[$key]; } // Otherwise we just compare else{ $args = $args && $val === $x[$key]; } } // This is where we call ourselves with all of the arrays we got passed if($aType === 'array'){ $comp = call_user_func_array(array(get_called_class(), 'array_diff_assoc_recursive'), $args); // An empty array means we are equal :-) if(count($comp) > 0){ $ret[$key] = $comp; } } // If the values don't match, then we found a difference elseif(!$args){ $ret[$key] = $val; } } return $ret; } } $a = [[1, 2, 3], 4, [5, 6 ], 8, 10]; $b = [[ 2, 3], 4, [5, 6 ] ]; $c = [[1, 2 ], 4, [5, 6, 7] ]; $d = [[ 2 ], 4, [5, 6, 7], 8, 9 ]; var_export(Tools::array_diff_assoc_recursive($a, $b, $c, $d));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.130.0080.00418.00
8.4.120.0020.00620.44
8.4.110.0170.00322.11
8.4.100.0090.01217.95
8.4.90.0070.00517.90
8.4.80.0100.01018.01
8.4.70.0060.00318.00
8.4.60.0090.01218.87
8.4.50.0130.00620.68
8.4.40.0000.00817.73
8.4.30.0090.01220.30
8.4.20.0160.00417.79
8.4.10.0100.01020.61
8.3.260.0120.00716.50
8.3.250.0080.00818.82
8.3.240.0130.00618.93
8.3.230.0100.01016.29
8.3.220.0110.00817.30
8.3.210.0040.00316.61
8.3.200.0050.00416.75
8.3.190.0050.00317.18
8.3.180.0120.00617.40
8.3.170.0090.00916.74
8.3.160.0090.00916.70
8.3.150.0170.00317.28
8.3.140.0080.01120.98
8.3.130.0030.00718.59
8.3.120.0100.00718.81
8.3.110.0080.00020.94
8.3.100.0090.00024.06
8.3.90.0030.01326.77
8.3.80.0060.00316.50
8.3.70.0100.00716.58
8.3.60.0070.01016.75
8.3.50.0070.00824.41
8.3.40.0100.00718.79
8.3.30.0040.01118.59
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0060.00326.16
8.2.290.0110.00820.80
8.2.280.0110.00718.72
8.2.270.0060.01217.09
8.2.260.0110.00718.86
8.2.250.0040.00416.78
8.2.240.0090.00917.14
8.2.230.0160.00322.58
8.2.220.0060.00337.54
8.2.210.0030.00526.77
8.2.200.0100.00016.75
8.2.190.0110.01116.75
8.2.180.0100.01025.92
8.2.170.0090.00618.95
8.2.160.0040.01122.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00426.35
8.2.110.0040.00420.21
8.2.100.0030.00919.51
8.2.90.0090.00017.90
8.2.80.0030.00520.39
8.2.70.0040.00417.63
8.2.60.0000.00817.63
8.2.50.0060.00317.63
8.2.40.0050.00318.22
8.2.30.0050.00218.06
8.2.20.0000.00918.05
8.2.10.0040.00419.17
8.2.00.0000.00819.40
8.1.330.0110.00722.00
8.1.320.0090.00216.10
8.1.310.0040.00416.86
8.1.300.0000.00817.87
8.1.290.0040.00418.88
8.1.280.0030.01025.92
8.1.270.0060.00323.99
8.1.260.0040.00428.09
8.1.250.0070.00028.09
8.1.240.0040.00423.91
8.1.230.0060.00620.97
8.1.220.0000.00817.74
8.1.210.0000.00818.84
8.1.200.0060.00317.36
8.1.190.0000.00717.35
8.1.180.0030.00618.10
8.1.170.0000.00818.54
8.1.160.0040.00418.76
8.1.150.0000.00718.82
8.1.140.0000.00818.90
8.1.130.0000.00820.15
8.1.120.0060.00317.45
8.1.110.0000.00817.48
8.1.100.0000.00717.43
8.1.90.0030.00717.49
8.1.80.0040.00617.46
8.1.70.0030.00517.52
8.1.60.0060.00417.60
8.1.50.0040.00517.54
8.1.40.0050.00517.40
8.1.30.0070.00217.63
8.1.20.0070.00417.67
8.1.10.0060.00717.61
8.1.00.0100.00817.45
8.0.300.0070.00020.16
8.0.290.0080.00016.75
8.0.280.0030.00320.13
8.0.270.0000.00717.93
8.0.260.0030.00520.22
8.0.250.0070.00016.88
8.0.240.0030.00616.84
8.0.230.0070.00316.95
8.0.220.0040.00416.88
8.0.210.0070.00016.79
8.0.200.0000.00716.94
8.0.190.0060.00516.88
8.0.180.0050.00716.92
8.0.170.0080.00516.86
8.0.160.0050.00816.88
8.0.150.0050.00716.76
8.0.140.0000.01016.82
8.0.130.0020.00915.09
8.0.120.0080.00416.83
8.0.110.0060.00416.73
8.0.100.0050.00516.90
8.0.90.0060.00416.86
8.0.80.0120.00516.92
8.0.70.0090.00416.88
8.0.60.0050.00516.90
8.0.50.0050.00416.85
8.0.30.0050.00917.01
8.0.20.0080.01016.96
8.0.10.0060.00416.92
8.0.00.0070.00816.95
7.4.330.0050.00015.55
7.4.320.0020.00516.59
7.4.300.0050.00216.62
7.4.290.0040.00616.43
7.4.280.0070.00216.61
7.4.270.0050.00416.57
7.4.260.0060.00214.89
7.4.250.0040.00516.54
7.4.240.0080.00316.55
7.4.230.0060.00316.63
7.4.220.0040.00516.51
7.4.210.0060.00716.61
7.4.200.0050.00316.46
7.4.190.0090.00216.65
7.4.180.0110.00216.49
7.4.160.0070.00516.56
7.4.150.0120.00016.50
7.4.140.0050.01016.43
7.4.130.0080.01216.53
7.4.120.0130.00516.47
7.4.110.0070.00716.51
7.4.100.0100.00616.47
7.4.90.0050.01016.48
7.4.80.0080.00616.53
7.4.70.0110.00416.54
7.4.60.0140.00516.37
7.4.50.0040.01116.38
7.4.40.0060.00916.26
7.4.30.0100.00616.34
7.4.20.0060.00816.43
7.4.10.0070.00716.48
7.4.00.0040.01216.54
7.3.330.0080.00316.40
7.3.320.0050.00514.71
7.3.310.0070.00416.29
7.3.300.0090.00216.37
7.3.290.0040.01016.33
7.3.280.0080.00816.35
7.3.270.0150.00016.26
7.3.260.0120.00516.49
7.3.250.0120.00216.48
7.3.240.0070.00816.41
7.3.230.0070.00916.36
7.3.220.0110.00416.14
7.3.210.0090.00916.45
7.3.200.0120.00516.33
7.3.190.0110.00616.29
7.3.180.0090.00516.28
7.3.170.0070.00916.36
7.3.160.0090.00716.33
7.3.150.0140.00216.51
7.3.140.0080.00816.41
7.3.130.0070.00816.50
7.3.120.0070.00816.26
7.3.110.0100.00616.25
7.3.100.0090.00716.41
7.3.90.0120.00516.58
7.3.80.0080.00816.45
7.3.70.0090.01116.45
7.3.60.0100.00616.51
7.3.50.0110.00616.47
7.3.40.0120.00716.45
7.3.30.0120.00416.36
7.3.20.0100.00818.31
7.3.10.0090.00718.07
7.3.00.0080.00818.30
7.2.340.0070.00716.34
7.2.330.0080.00816.61
7.2.320.0070.00816.65
7.2.310.0070.00916.66
7.2.300.0100.00916.48
7.2.290.0070.01016.47
7.2.280.0090.00716.64
7.2.270.0170.00016.61
7.2.260.0080.00816.43
7.2.250.0100.00616.45
7.2.240.0120.00416.54
7.2.230.0100.00716.59
7.2.220.0140.00516.64
7.2.210.0130.00316.41
7.2.200.0100.01016.68
7.2.190.0150.00216.57
7.2.180.0100.01016.65
7.2.170.0080.01116.62
7.2.160.0080.01116.47
7.2.150.0130.00418.45
7.2.140.0100.00618.49
7.2.130.0110.00518.48
7.2.120.0090.01018.42
7.2.110.0140.00318.48
7.2.100.0060.00918.46
7.2.90.0110.00718.46
7.2.80.0070.01018.51
7.2.70.0080.01018.48
7.2.60.0100.00718.45
7.2.50.0090.00818.40
7.2.40.0070.01118.53
7.2.30.0090.00918.46
7.2.20.0100.00718.36
7.2.10.0120.00418.37
7.2.00.0110.00618.35

preferences:
32.18 ms | 403 KiB | 5 Q