3v4l.org

run code in 300+ PHP versions simultaneously
<?php $errmsg = NULL; function wd_check_serialization( $string ) { $str = 's'; $array = 'a'; $integer = 'i'; $any = '[^}]*?'; $count = '\d+'; $content = '"(?:\\\";|.)*?";'; $open_tag = '\{'; $close_tag = '\}'; $parameter = "($str|$array|$integer|$any):($count)" . "(?:[:]($open_tag|$content)|[;])"; $preg = "/$parameter|($close_tag)/"; if( !preg_match_all( $preg, $string, $matches ) ) { $errmsg = 'not a serialized string'; return false; } $open_arrays = 0; foreach( $matches[1] AS $key => $value ) { if( !empty( $value ) && ( $value != $array xor $value != $str xor $value != $integer ) ) { echo 'undefined datatype'; return false; } if( $value == $array ) { $open_arrays++; if( $matches[3][$key] != '{' ) { echo 'open tag expected'; return false; } } if( $value == '' ) { if( $matches[4][$key] != '}' ) { $errmsg = 'close tag expected'; return false; } $open_arrays--; } if( $value == $str ) { $aVar = ltrim( $matches[3][$key], '"' ); $aVar = rtrim( $aVar, '";' ); if( strlen( $aVar ) != $matches[2][$key] ) { echo 'stringlen for string not match'; return false; } } if( $value == $integer ) { if( !empty( $matches[3][$key] ) ) { echo 'unexpected data'; return false; } if( !is_integer( (int)$matches[2][$key] ) ) { $errmsg = 'integer expected'; return false; } } } if( $open_arrays != 0 ) { echo 'wrong setted arrays'; return false; } return true; } var_dump(wd_check_serialization('a:1:{i:0;a:10:{s:2:"id";s:3:"390";s:12:"variation_id";s:3:"393";s:4:"name";s:38:"Serviette Absolut mit Gastro-Logodruck";s:3:"qty";s:1:"1";s:9:"item_meta";a:3:{i:0;a:2:{s:9:"meta_name";s:51:"Geben Sie bitte hier die gewünschte Zusatzfarbe an";s:10:"meta_value";s:12:"schwarzgold";}i:1;a:2:{s:9:"meta_name";s:6:"pa_vpe";s:10:"meta_value";s:6:"18-900";}i:2;a:2:{s:9:"meta_name";s:12:"pa_erstdruck";s:10:"meta_value";s:2:"ja";}}s:13:"line_subtotal";s:3:"360";s:17:"line_subtotal_tax";s:4:"68.4";s:10:"line_total";s:3:"360";s:8:"line_tax";s:4:"68.4";s:9:"tax_class";s:19:"gesetzliche-mwst-19";}}'));

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.3.60.0110.00416.63
8.3.50.0090.01022.27
8.3.40.0110.00418.99
8.3.30.0110.00419.12
8.3.20.0050.00220.34
8.3.10.0040.00423.66
8.3.00.0000.00819.38
8.2.180.0030.01318.66
8.2.170.0090.00622.96
8.2.160.0140.00020.49
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0130.00626.16
8.2.120.0040.00422.37
8.2.110.0100.00021.06
8.2.100.0090.00317.94
8.2.90.0080.00019.33
8.2.80.0040.00418.00
8.2.70.0030.00718.00
8.2.60.0060.00318.15
8.2.50.0030.00918.07
8.2.40.0040.00420.01
8.2.30.0030.00618.22
8.2.20.0000.00717.84
8.2.10.0040.00418.27
8.2.00.0040.00417.88
8.1.280.0100.00725.92
8.1.270.0000.00923.77
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00321.27
8.1.230.0080.00317.64
8.1.220.0050.00317.74
8.1.210.0090.00018.77
8.1.200.0060.00317.48
8.1.190.0040.00417.36
8.1.180.0090.00018.10
8.1.170.0080.00318.92
8.1.160.0040.00422.06
8.1.150.0000.00818.91
8.1.140.0040.00417.65
8.1.130.0050.00217.84
8.1.120.0030.00517.73
8.1.110.0090.00017.65
8.1.100.0100.00017.73
8.1.90.0040.00417.65
8.1.80.0000.00717.64
8.1.70.0000.00817.59
8.1.60.0030.00517.83
8.1.50.0040.00417.75
8.1.40.0040.00417.63
8.1.30.0050.00317.88
8.1.20.0040.00417.82
8.1.10.0040.00417.79
8.1.00.0040.00417.70
8.0.300.0060.00618.77
8.0.290.0040.00416.88
8.0.280.0000.00718.57
8.0.270.0030.00316.95
8.0.260.0050.00217.22
8.0.250.0000.01017.22
8.0.240.0000.00817.09
8.0.230.0060.00317.05
8.0.220.0000.00717.09
8.0.210.0080.00017.09
8.0.200.0030.00317.04
8.0.190.0050.00317.23
8.0.180.0040.00417.17
8.0.170.0000.00817.12
8.0.160.0000.00716.99
8.0.150.0040.00417.13
8.0.140.0050.00317.10
8.0.130.0030.00313.51
8.0.120.0040.00417.06
8.0.110.0000.00717.12
8.0.100.0080.00017.07
8.0.90.0000.00716.99
8.0.80.0030.01317.13
8.0.70.0040.00416.98
8.0.60.0000.00817.08
8.0.50.0040.00417.09
8.0.30.0110.00817.21
8.0.20.0120.00617.40
8.0.10.0000.00717.21
8.0.00.0060.01216.88
7.4.330.0030.00315.00
7.4.320.0030.00316.80
7.4.300.0000.00716.89
7.4.290.0070.00016.82
7.4.280.0040.00416.82
7.4.270.0040.00416.91
7.4.260.0070.00016.84
7.4.250.0040.00416.89
7.4.240.0010.00616.85
7.4.230.0040.00416.58
7.4.220.0100.01016.95
7.4.210.0090.01016.80
7.4.200.0050.00216.64
7.4.190.0040.00416.84
7.4.160.0130.00916.74
7.4.150.0130.00717.40
7.4.140.0090.01117.86
7.4.130.0100.00816.77
7.4.120.0060.01316.85
7.4.110.0090.00916.88
7.4.100.0130.01016.91
7.4.90.0070.01116.77
7.4.80.0100.01319.39
7.4.70.0140.00316.74
7.4.60.0100.00716.76
7.4.50.0040.00416.76
7.4.40.0030.01222.77
7.4.30.0090.00816.76
7.4.00.0100.00615.06
7.3.330.0000.00613.52
7.3.320.0040.00413.36
7.3.310.0050.00316.46
7.3.300.0040.00416.61
7.3.290.0090.00616.55
7.3.280.0030.01416.58
7.3.270.0060.01317.40
7.3.260.0060.01216.55
7.3.250.0130.01216.58
7.3.240.0090.00916.58
7.3.230.0090.00916.77
7.3.210.0110.01116.97
7.3.200.0100.01016.54
7.3.190.0140.00316.61
7.3.180.0130.00316.43
7.3.170.0090.01216.65
7.3.160.0000.01616.84
7.3.120.0100.00515.13
7.3.110.0090.00614.77
7.3.100.0030.01315.31
7.3.90.0120.00015.13
7.3.80.0030.00914.80
7.3.70.0090.00314.84
7.3.60.0000.01115.11
7.3.50.0030.00914.96
7.3.40.0040.00814.79
7.3.30.0070.00714.98
7.3.20.0030.00716.88
7.3.10.0090.00317.06
7.3.00.0100.00316.90
7.2.330.0140.00316.90
7.2.320.0060.01016.79
7.2.310.0110.00716.90
7.2.300.0070.01016.86
7.2.290.0090.00916.65
7.2.250.0180.00015.30
7.2.240.0100.01015.20
7.2.230.0030.01015.54
7.2.220.0070.01015.38
7.2.210.0120.00315.56
7.2.200.0060.00615.48
7.2.190.0140.00315.49
7.2.180.0070.00615.30
7.2.170.0090.00415.26
7.2.00.0000.01219.55
7.1.330.0030.01015.75
7.1.320.0090.00615.92
7.1.310.0040.01216.27
7.1.300.0050.00515.73
7.1.290.0060.00615.91
7.1.280.0040.00815.84
7.1.270.0030.00616.11
7.1.260.0000.01316.22
7.1.200.0030.01015.90
7.1.100.0650.00716.42
7.1.70.0060.00317.46
7.1.60.0140.01119.46
7.1.50.0090.01217.18
7.1.00.0070.07322.42
7.0.200.0460.01014.86
7.0.140.0000.06721.95
7.0.60.0100.06019.96
7.0.50.0000.07318.04
7.0.40.0000.05720.07
7.0.30.0600.06320.10
7.0.20.0170.08720.25
7.0.10.0130.08020.11
7.0.00.0070.08720.30
5.6.280.0070.07321.11
5.6.210.0070.08720.55
5.6.200.0070.03718.22
5.6.190.0030.06720.43
5.6.180.0230.07720.55
5.6.170.0400.07320.44
5.6.160.0100.04020.48
5.6.150.0130.07018.17
5.6.140.0070.03718.20
5.6.130.0030.08318.27
5.6.120.0000.04321.05
5.6.110.0070.08321.04
5.6.100.0000.04721.18
5.6.90.0030.07320.92
5.6.80.0070.05320.44
5.6.70.4470.04320.45
5.5.350.0170.04320.38
5.5.340.0130.07018.05
5.5.330.0030.06720.43
5.5.320.0370.06720.34
5.5.310.0270.07720.44
5.5.300.0170.07717.98
5.5.290.0070.07718.08
5.5.280.0030.07320.69
5.5.270.0070.07020.90
5.5.260.0030.04321.01
5.5.250.0030.09020.81
5.5.240.0200.07720.30
5.4.450.0800.07719.18
5.4.440.1030.05319.47
5.4.430.0100.05719.66
5.4.420.0700.06719.59
5.4.410.0970.05719.35
5.4.400.0370.06018.86
5.4.390.0270.04319.20
5.4.380.0330.07318.63
5.4.370.0370.05018.56
5.4.360.0200.05718.57
5.4.350.0270.05718.76
5.4.340.0200.06018.79
5.4.320.0070.03512.55
5.4.310.0050.04412.55
5.4.300.0050.03712.55
5.4.290.0090.04712.55
5.4.280.0100.05012.45
5.4.270.0110.04312.45
5.4.260.0140.04512.44
5.4.250.0050.04112.45
5.4.240.0040.04412.44
5.4.230.0070.04212.44
5.4.220.0090.03612.44
5.4.210.0050.03912.44
5.4.200.0070.03912.44
5.4.190.0100.03412.43
5.4.180.0120.05112.43
5.4.170.0060.05312.45
5.4.160.0100.04612.43
5.4.150.0070.04912.43
5.4.140.0100.04812.12
5.4.130.0050.05112.10
5.4.120.0100.04712.07
5.4.110.0110.04812.06
5.4.100.0100.04412.06
5.4.90.0090.04912.06
5.4.80.0110.03912.05
5.4.70.0090.03912.05
5.4.60.0070.04012.05
5.4.50.0060.04112.06
5.4.40.0070.03912.05
5.4.30.0090.03612.04
5.4.20.0080.05112.04
5.4.10.0100.04412.04
5.4.00.0060.03811.53
5.3.290.0060.04512.81
5.3.280.0070.04012.74
5.3.270.0090.04112.75
5.3.260.0090.04012.75
5.3.250.0050.05112.75
5.3.240.0100.05012.75
5.3.230.0100.04312.74
5.3.220.0050.04212.71
5.3.210.0090.04712.71
5.3.200.0030.04912.71
5.3.190.0080.04412.71
5.3.180.0130.04312.71
5.3.170.0100.05112.71
5.3.160.0100.05012.70
5.3.150.0120.05812.71
5.3.140.0080.05112.70
5.3.130.0150.07112.69
5.3.120.0130.05112.69
5.3.110.0090.05312.70
5.3.100.0130.04812.18
5.3.90.0090.04512.16
5.3.80.0100.04812.16
5.3.70.0150.03812.16
5.3.60.0120.04612.14
5.3.50.0060.05012.08
5.3.40.0080.04812.08
5.3.30.0030.06412.05
5.3.20.0080.04811.82
5.3.10.0070.04911.79
5.3.00.0080.04711.78
5.2.170.0080.0319.29
5.2.160.0050.0319.29
5.2.150.0080.0299.29
5.2.140.0040.0319.28
5.2.130.0030.0329.24
5.2.120.0060.0309.24
5.2.110.0070.0339.25
5.2.100.0080.0359.24
5.2.90.0070.0399.24
5.2.80.0060.0419.24
5.2.70.0050.0429.23
5.2.60.0070.0399.20
5.2.50.0070.0389.16
5.2.40.0090.0359.14
5.2.30.0040.0429.12
5.2.20.0080.0379.12
5.2.10.0060.0339.01
5.2.00.0070.0298.88
5.1.60.0060.0308.21
5.1.50.0070.0378.20
5.1.40.0040.0338.19
5.1.30.0060.0368.54
5.1.20.0070.0378.56
5.1.10.0030.0388.28
5.1.00.0100.0328.28
5.0.50.0060.0266.77
5.0.40.0100.0296.63
5.0.30.0050.0426.44
5.0.20.0060.0246.41
5.0.10.0060.0266.38
5.0.00.0030.0406.38
4.4.90.0020.0234.78
4.4.80.0030.0224.75
4.4.70.0020.0234.76
4.4.60.0050.0144.75
4.4.50.0040.0164.77
4.4.40.0040.0264.78
4.4.30.0040.0164.77
4.4.20.0060.0204.84
4.4.10.0030.0224.85
4.4.00.0030.0324.80
4.3.110.0040.0174.71
4.3.100.0050.0144.70
4.3.90.0030.0164.68
4.3.80.0020.0294.69
4.3.70.0050.0154.68
4.3.60.0010.0184.68
4.3.50.0020.0204.68
4.3.40.0020.0274.64
4.3.30.0030.0163.45
4.3.20.0020.0173.42
4.3.10.0020.0183.38
4.3.00.0230.01710.53

preferences:
54.33 ms | 401 KiB | 5 Q