3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * Polyfills. */ function stripslashes_from_strings_only( $value ) { return is_string( $value ) ? stripslashes( $value ) : $value; } function is_serialized( $data, $strict = true ) { // If it isn't a string, it isn't serialized. if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( 'N;' === $data ) { return true; } if ( strlen( $data ) < 4 ) { return false; } if ( ':' !== $data[1] ) { return false; } if ( $strict ) { $lastc = substr( $data, -1 ); if ( ';' !== $lastc && '}' !== $lastc ) { return false; } } else { $semicolon = strpos( $data, ';' ); $brace = strpos( $data, '}' ); // Either ; or } must exist. if ( false === $semicolon && false === $brace ) { return false; } // But neither must be in the first X characters. if ( false !== $semicolon && $semicolon < 3 ) { return false; } if ( false !== $brace && $brace < 4 ) { return false; } } $token = $data[0]; switch ( $token ) { case 's': if ( $strict ) { if ( '"' !== substr( $data, -2, 1 ) ) { return false; } } elseif ( false === strpos( $data, '"' ) ) { return false; } // Or else fall through. case 'a': case 'O': case 'E': return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); case 'b': case 'i': case 'd': $end = $strict ? '$' : ''; return (bool) preg_match( "/^{$token}:[0-9.E+-]+;$end/", $data ); } return false; } function map_deep( $value, $callback ) { if ( is_array( $value ) ) { foreach ( $value as $index => $item ) { $value[ $index ] = map_deep( $item, $callback ); } } elseif ( is_object( $value ) ) { $object_vars = get_object_vars( $value ); foreach ( $object_vars as $property_name => $property_value ) { $value->$property_name = map_deep( $property_value, $callback ); } } else { $value = call_user_func( $callback, $value ); } return $value; } function maybe_unserialize( $data ) { if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in. return @unserialize( trim( $data ) ); } return $data; } /* * Test. */ $test_data = 'a:2:{i:0;O:14:"SuperCustomXyz":1:{s:17:" SuperCustomXyz x";s:4:"test";}s:8:"testdata";a:2:{s:1:"a";i:1;s:1:"b";i:2;}}'; $unserialized = maybe_unserialize($test_data); $res = map_deep($unserialized, 'stripslashes_from_strings_only'); print_r($res);

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.10.0160.00323.76
8.3.140.0030.00616.71
8.3.130.0090.00017.16
8.3.120.0060.00318.98
8.3.110.0060.00320.94
8.3.100.0120.00624.06
8.3.90.0040.00426.77
8.3.80.0060.00317.97
8.3.70.0070.01018.78
8.3.60.0090.01218.68
8.3.50.0100.01016.93
8.3.40.0170.00723.65
8.3.30.0150.00018.96
8.3.20.0080.00024.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.260.0110.00416.87
8.2.250.0030.00619.05
8.2.240.0160.00317.40
8.2.230.0050.00322.58
8.2.220.0030.00637.54
8.2.210.0040.00426.77
8.2.200.0080.00316.88
8.2.190.0110.00716.88
8.2.180.0170.00316.88
8.2.170.0100.00622.96
8.2.160.0030.01022.96
8.2.150.0040.00425.66
8.2.140.0030.00624.66
8.2.130.0000.00826.16
8.2.120.0100.01020.69
8.2.110.0060.00321.18
8.2.100.0120.00017.97
8.2.90.0030.00617.91
8.2.80.0030.00619.88
8.2.70.0090.00018.00
8.2.60.0050.00317.88
8.2.50.0000.00817.88
8.2.40.0000.00818.05
8.2.30.0000.00817.85
8.2.20.0160.00018.01
8.2.10.0090.00918.00
8.2.00.0160.00018.04
8.1.300.0100.01020.04
8.1.290.0030.00730.84
8.1.280.0070.01125.92
8.1.270.0030.00523.85
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0030.00622.61
8.1.230.0110.00020.97
8.1.220.0040.00417.91
8.1.210.0080.00018.97
8.1.200.0030.00617.73
8.1.190.0030.00617.61
8.1.180.0030.00518.10
8.1.170.0050.00317.62
8.1.160.0110.00617.72
8.1.150.0160.00017.52
8.1.140.0070.01017.61
8.1.130.0070.00517.51
8.1.120.0060.00617.58
8.1.110.0040.00917.73
8.1.100.0080.00417.66
8.1.90.0070.00417.63
8.1.80.0070.00417.68
8.1.70.0050.00517.66
8.1.60.0040.00817.80
8.1.50.0060.00617.61
8.1.40.0030.01017.79
8.1.30.0000.00917.68
8.1.20.0060.00417.73
8.1.10.0050.00517.74
8.1.00.0090.00017.56
8.0.300.0000.00720.11
8.0.290.0020.00517.13
8.0.280.0090.00517.00
8.0.270.0130.00016.88
8.0.260.0070.00716.92
8.0.250.0120.00417.07
8.0.240.0080.00917.09
8.0.230.0080.00816.98
8.0.220.0150.00017.03
8.0.210.0110.00416.97
8.0.200.0070.00716.99
8.0.190.0100.00517.06
8.0.180.0130.00317.10
8.0.170.0110.00517.04
8.0.160.0000.01517.01
8.0.150.0100.00616.95
8.0.140.0150.00016.96
8.0.130.0110.00316.95
8.0.120.0110.00016.91
8.0.110.0070.01016.90
8.0.100.0160.00017.02
8.0.90.0120.00417.07
8.0.80.0050.01016.94
8.0.70.0040.01217.05
8.0.60.0130.00617.02
8.0.50.0170.00017.01
8.0.30.0080.00816.91
8.0.20.0110.00417.05
8.0.10.0030.00717.14
8.0.00.0100.00317.22
7.4.330.0130.00015.66
7.4.320.0070.01016.70
7.4.300.0100.00516.60
7.4.290.0080.00816.63
7.4.280.0050.01116.73
7.4.270.0080.00816.75
7.4.260.0160.00016.61
7.4.250.0180.00416.71
7.4.240.0120.00616.68
7.4.230.0130.00316.75
7.4.220.0120.00316.57
7.4.210.0150.00016.67
7.4.200.0140.00316.80
7.4.190.0140.00016.73
7.4.180.0150.00016.81
7.4.160.0070.00716.74
7.4.150.0090.00616.81
7.4.140.0090.00416.69
7.4.130.0110.00416.56
7.4.120.0120.00216.70
7.4.110.0110.00316.75
7.4.100.0070.00716.63
7.4.90.0140.00016.68
7.4.80.0100.00516.67
7.4.70.0130.00016.69
7.4.60.0090.00716.55
7.4.50.0170.00016.54
7.4.40.0100.00316.62
7.4.30.0110.00316.74
7.4.20.0100.00316.60
7.4.10.0130.00016.60
7.4.00.0080.00816.50
7.3.330.0150.00016.59
7.3.320.0140.00016.43
7.3.310.0110.00316.46
7.3.300.0150.00016.61
7.3.290.0110.00416.50
7.3.280.0110.00416.41
7.3.270.0070.00716.51
7.3.260.0120.00316.46
7.3.250.0000.01416.46
7.3.240.0120.00316.50
7.3.230.0090.00516.56
7.3.220.0100.00516.37
7.3.210.0120.00316.46
7.3.200.0090.00516.34
7.3.190.0150.00016.59
7.3.180.0130.00216.48
7.3.170.0120.00316.59
7.3.160.0100.00316.53
7.3.150.0110.00416.39
7.3.140.0050.01016.40
7.3.130.0140.00016.45
7.3.120.0140.00016.45
7.3.110.0070.00716.31
7.3.100.0070.00716.29
7.3.90.0090.00516.81
7.3.80.0060.00916.65
7.3.70.0070.00716.64
7.3.60.0050.00916.51
7.3.50.0100.00616.48
7.3.40.0150.00016.71
7.3.30.0080.00516.52
7.3.20.0120.00418.37
7.3.10.0070.00718.16
7.3.00.0110.00718.16
7.2.340.0140.00016.69
7.2.330.0090.00616.73
7.2.320.0140.00016.71
7.2.310.0090.00616.69
7.2.300.0100.00516.62
7.2.290.0100.00516.54
7.2.280.0090.00516.63
7.2.270.0110.00516.58
7.2.260.0140.00016.74
7.2.250.0070.00716.58
7.2.240.0120.00316.64
7.2.230.0110.00316.67
7.2.220.0120.00316.72
7.2.210.0110.00316.67
7.2.200.0120.00316.91
7.2.190.0080.00616.77
7.2.180.0140.00016.68
7.2.170.0100.00316.75
7.2.160.0140.00016.78
7.2.150.0120.00518.61
7.2.140.0100.00518.64
7.2.130.0130.00318.68
7.2.120.0080.00618.45
7.2.110.0140.00018.45
7.2.100.0040.01118.51
7.2.90.0110.00418.47
7.2.80.0110.00418.67
7.2.70.0160.00018.67
7.2.60.0090.00618.66
7.2.50.0070.00718.61
7.2.40.0150.00018.66
7.2.30.0070.00718.66
7.2.20.0050.00918.67
7.2.10.0150.00018.48
7.2.00.0080.00618.68
7.1.330.0090.00517.28
7.1.320.0050.00917.43
7.1.310.0150.00017.32
7.1.300.0070.00717.25
7.1.290.0100.00517.23
7.1.280.0140.00017.20
7.1.270.0070.00717.40
7.1.260.0070.00717.38
7.1.250.0100.00317.15
7.1.240.0140.00017.15
7.1.230.0150.00017.33
7.1.220.0060.00917.23
7.1.210.0120.00217.39
7.1.200.0110.00317.38
7.1.190.0080.00517.41
7.1.180.0100.00617.14
7.1.170.0090.00417.30
7.1.160.0130.00017.14
7.1.150.0110.00417.21
7.1.140.0110.00317.44
7.1.130.0070.00717.38
7.1.120.0100.00517.19
7.1.110.0090.00517.50
7.1.100.0050.00817.43
7.1.90.0090.00517.48
7.1.80.0070.00717.54
7.1.70.0030.01017.27
7.1.60.0070.00717.63
7.1.50.0150.00017.39
7.1.40.0140.00017.50
7.1.30.0140.00017.53
7.1.20.0070.00717.38
7.1.10.0140.00017.48
7.1.00.0070.00717.31
7.0.330.0070.00717.18
7.0.320.0140.00017.20
7.0.310.0090.00517.22
7.0.300.0150.00017.15
7.0.290.0130.00017.14
7.0.280.0090.00517.07
7.0.270.0090.00417.18
7.0.260.0150.00017.10
7.0.250.0090.00417.02
7.0.240.0100.00717.29
7.0.230.0100.00317.07
7.0.220.0070.00717.06
7.0.210.0110.00217.14
7.0.200.0100.00317.00
7.0.190.0090.00417.15
7.0.180.0090.00416.95
7.0.170.0080.00417.23
7.0.160.0060.00616.95
7.0.150.0080.00416.95
7.0.140.0100.00316.92
7.0.130.0140.00017.13
7.0.120.0070.00717.03
7.0.110.0100.00316.91
7.0.100.0090.00517.06
7.0.90.0150.00016.93
7.0.80.0150.00016.86
7.0.70.0030.01017.09
7.0.60.0110.00417.05
7.0.50.0130.00016.98
7.0.40.0110.00217.16
7.0.30.0130.00017.18
7.0.20.0070.00716.89
7.0.10.0140.00017.05
7.0.00.0070.00716.86
5.6.400.0100.00315.78
5.6.390.0140.00015.82
5.6.380.0070.00716.03
5.6.370.0090.00515.89
5.6.360.0000.01315.89
5.6.350.0090.00515.87
5.6.340.0050.00815.97
5.6.330.0130.00015.92
5.6.320.0110.00315.77
5.6.310.0000.01315.88
5.6.300.0090.00415.82
5.6.290.0130.00016.03
5.6.280.0130.00015.82
5.6.270.0000.01315.79
5.6.260.0090.00415.86
5.6.250.0090.00415.95
5.6.240.0110.00316.12
5.6.230.0110.00315.99
5.6.220.0100.00316.00
5.6.210.0120.00316.12
5.6.200.0130.00016.28
5.6.190.0130.00016.13
5.6.180.0050.00916.18
5.6.170.0120.00216.12
5.6.160.0130.00016.17
5.6.150.0130.00016.13
5.6.140.0110.00316.11
5.6.130.0090.00415.99
5.6.120.0100.00316.07
5.6.110.0090.00416.09
5.6.100.0140.00016.09
5.6.90.0110.00316.02
5.6.80.0070.00716.00
5.6.70.0090.00415.98
5.6.60.0090.00316.07
5.6.50.0040.00915.89
5.6.40.0040.00816.14
5.6.30.0090.00416.09
5.6.20.0110.00215.87
5.6.10.0100.00315.87
5.6.00.0000.01315.91
5.5.380.0120.00316.18
5.5.370.0100.00316.08
5.5.360.0110.00316.01
5.5.350.0090.00415.98
5.5.340.0070.00716.00
5.5.330.0030.01016.01
5.5.320.0070.00715.90
5.5.310.0140.00015.97
5.5.300.0060.00615.86
5.5.290.0090.00415.95
5.5.280.0120.00415.82
5.5.270.0130.00015.98
5.5.260.0080.00515.77
5.5.250.0090.00615.97
5.5.240.0100.00315.95
5.5.230.0130.00016.06
5.5.220.0110.00315.97
5.5.210.0100.00316.09
5.5.200.0140.00015.99
5.5.190.0100.00315.86
5.5.180.0080.00515.89
5.5.170.0070.00715.91
5.5.160.0090.00315.83
5.5.150.0100.00215.91
5.5.140.0030.01015.78
5.5.130.0090.00415.86
5.5.120.0130.00015.82
5.5.110.0130.00015.80
5.5.100.0050.01015.89
5.5.90.0090.00616.06
5.5.80.0040.00815.90
5.5.70.0130.00016.08
5.5.60.0050.00716.00
5.5.50.0090.00316.04
5.5.40.0060.00616.00
5.5.30.0060.00615.88
5.5.20.0060.00615.95
5.5.10.0120.00015.84
5.5.00.0090.00315.92
5.4.450.0100.00015.66
5.4.440.0100.00015.66
5.4.430.0050.00515.66
5.4.420.0080.00315.66
5.4.410.0000.01115.66
5.4.400.0000.01115.66
5.4.390.0110.00015.66
5.4.380.0050.00515.66
5.4.370.0050.00515.66
5.4.360.0060.00615.66
5.4.350.0110.00015.66
5.4.340.0080.00315.66
5.4.330.0040.00715.66
5.4.320.0070.00415.66
5.4.310.0030.00815.66
5.4.300.0120.00015.66
5.4.290.0090.00315.66
5.4.280.0110.00015.66
5.4.270.0100.00015.66
5.4.260.0070.00315.66
5.4.250.0050.00515.66
5.4.240.0070.00415.66
5.4.230.0060.00415.66
5.4.220.0060.00415.66
5.4.210.0100.00015.66
5.4.200.0090.00315.66
5.4.190.0100.00015.66
5.4.180.0050.00515.66
5.4.170.0000.01115.66
5.4.160.0100.00015.66
5.4.150.0020.00715.66
5.4.140.0040.00715.66
5.4.130.0050.00515.66
5.4.120.0080.00315.66
5.4.110.0050.00515.66
5.4.100.0050.00515.66
5.4.90.0070.00315.66
5.4.80.0030.00715.66
5.4.70.0100.00015.66
5.4.60.0050.00515.66
5.4.50.0100.00015.66
5.4.40.0050.00515.66
5.4.30.0030.00615.66
5.4.20.0030.00715.66
5.4.10.0000.01015.66
5.4.00.0080.00215.66
5.3.290.0100.00015.66
5.3.280.0040.00815.66
5.3.270.0070.00415.66
5.3.260.0110.00015.66
5.3.250.0070.00415.66
5.3.240.0070.00415.66
5.3.230.0070.00315.66
5.3.220.0080.00215.66
5.3.210.0050.00515.66
5.3.200.0110.00015.66
5.3.190.0080.00315.66
5.3.180.0100.00015.66
5.3.170.0100.00015.66
5.3.160.0110.00015.66
5.3.150.0050.00515.66
5.3.140.0100.00015.66
5.3.130.0080.00315.66
5.3.120.0060.00415.66
5.3.110.0050.00515.66
5.3.100.0000.01015.66
5.3.90.0030.00715.66
5.3.80.0080.00315.66
5.3.70.0070.00315.66
5.3.60.0000.01015.66
5.3.50.0050.00515.66
5.3.40.0070.00315.66
5.3.30.0030.00715.66
5.3.20.0100.00015.66
5.3.10.0100.00015.66
5.3.00.0050.00515.66
5.2.170.0060.00315.66
5.2.160.0040.00415.66
5.2.150.0080.00015.66
5.2.140.0000.00915.66
5.2.130.0090.00015.66
5.2.120.0090.00015.66
5.2.110.0050.00515.66
5.2.100.0110.00015.66
5.2.90.0070.00315.66
5.2.80.0060.00315.66
5.2.70.0100.00015.66
5.2.60.0000.01015.66
5.2.50.0020.00615.66
5.2.40.0000.01015.66
5.2.30.0030.00615.66
5.2.20.0030.00615.66
5.2.10.0040.00415.66
5.2.00.0090.00015.66
5.1.60.0070.00015.66
5.1.50.0080.00015.66
5.1.40.0070.00015.66
5.1.30.0050.00315.66
5.1.20.0040.00415.66
5.1.10.0060.00215.66
5.1.00.0080.00015.66
5.0.50.0060.00015.66
5.0.40.0050.00215.66
5.0.30.0000.00615.66
5.0.20.0060.00015.66
5.0.10.0030.00315.66
5.0.00.0040.00215.66
4.4.90.0000.00415.66
4.4.80.0040.00015.66
4.4.70.0040.00015.66
4.4.60.0040.00015.66
4.4.50.0030.00115.66
4.4.40.0040.00015.66
4.4.30.0000.00415.66
4.4.20.0040.00015.66
4.4.10.0040.00015.66
4.4.00.0040.00015.66
4.3.110.0020.00215.66
4.3.100.0030.00015.66
4.3.90.0030.00115.66
4.3.80.0040.00015.66
4.3.70.0040.00015.66
4.3.60.0000.00415.66
4.3.50.0000.00415.66
4.3.40.0020.00215.66
4.3.30.0000.00315.66
4.3.20.0000.00315.66
4.3.10.0000.00315.66
4.3.00.0030.00015.66

preferences:
27.41 ms | 403 KiB | 5 Q