3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'My Interests:379{Commercial:0,Consumer:1,Wholesale Reseller:2},Test Group:1234{Test One:1,Test 2:2}'; $regex = '(?<group_name>[a-zA-Z0-9 _]+):(?<group_id>[0-9]+)(?={)|(?<=[{,])(?<option_name>[^:]+):(?<option_id>[^,}]+)(?=[,}])'; preg_match_all("/$regex/", $string, $matches); //print_r($matches); $groups = array_combine(array_filter($matches['group_name']), array_filter($matches['group_id'], function ($v) { return $v !== '';})); $options = array_combine(array_filter($matches['option_name']), array_filter($matches['option_id'], function ($v) { return $v !== '';})); print_r($groups); print_r($options); $output = array(); for ($i = 0; $i < count($matches['group_name']); $i++) { if ($matches['group_name'][$i] != '') { // new group $this_group = $matches['group_name'][$i]; $output[$this_group] = array('id' => $matches['group_id'][$i]); } else { // option for this group $output[$this_group]['options'][$matches['option_name'][$i]] = $matches['option_id'][$i]; } } print_r($output); $output = array(); $this_group = -1; for ($i = 0; $i < count($matches['group_name']); $i++) { if ($matches['group_name'][$i] != '') { // new group $this_group++; $output[$this_group] = array('name' => $matches['group_name'][$i], 'id' => $matches['group_id'][$i]); } else { // option for this group $output[$this_group]['options'][$matches['option_name'][$i]] = $matches['option_id'][$i]; } } print_r($output);

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.130.0100.00018.72
8.3.120.0060.00618.97
8.3.110.0150.00420.94
8.3.100.0110.00024.06
8.3.90.0060.00926.77
8.3.80.0030.00619.36
8.3.70.0070.00717.00
8.3.60.0090.00918.77
8.3.50.0080.01217.79
8.3.40.0040.01119.07
8.3.30.0060.00918.92
8.3.20.0050.00221.88
8.3.10.0090.00020.77
8.3.00.0060.00319.63
8.2.250.0090.00017.11
8.2.240.0100.01017.47
8.2.230.0070.00422.58
8.2.220.0090.00037.54
8.2.210.0080.00026.77
8.2.200.0060.00318.88
8.2.190.0120.00617.00
8.2.180.0130.00618.66
8.2.170.0150.00022.96
8.2.160.0140.00020.68
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0090.00020.08
8.2.110.0060.00320.50
8.2.100.0040.00818.28
8.2.90.0000.00918.25
8.2.80.0050.00519.16
8.2.70.0000.00818.00
8.2.60.0000.00818.00
8.2.50.0050.00318.05
8.2.40.0080.00018.30
8.2.30.0080.00019.66
8.2.20.0070.00018.21
8.2.10.0040.00419.53
8.2.00.0070.00018.31
8.1.300.0080.01118.30
8.1.290.0080.00330.84
8.1.280.0130.02025.92
8.1.270.0060.00320.34
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.86
8.1.230.0120.00020.84
8.1.220.0030.00618.94
8.1.210.0090.00018.77
8.1.200.0080.00017.73
8.1.190.0000.00917.60
8.1.180.0000.00818.10
8.1.170.0040.00417.88
8.1.160.0070.00018.95
8.1.150.0040.00418.95
8.1.140.0050.00319.04
8.1.130.0080.00320.22
8.1.120.0040.00417.59
8.1.110.0090.00317.68
8.1.100.0000.00817.71
8.1.90.0040.00417.55
8.1.80.0040.00417.69
8.1.70.0040.00417.56
8.1.60.0040.00417.82
8.1.50.0050.00317.70
8.1.40.0060.00317.76
8.1.30.0000.00817.88
8.1.20.0000.00917.84
8.1.10.0040.00417.71
8.1.00.0040.00417.79
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00518.25
8.0.270.0070.00018.19
8.0.260.0000.00718.52
8.0.250.0060.00317.15
8.0.240.0040.00817.07
8.0.230.0070.00017.17
8.0.220.0000.00817.10
8.0.210.0040.00417.04
8.0.200.0030.00617.04
8.0.190.0000.00717.04
8.0.180.0040.00417.00
8.0.170.0060.00317.14
8.0.160.0000.00717.15
8.0.150.0000.00716.98
8.0.140.0040.00417.09
8.0.130.0000.00613.45
8.0.120.0040.00416.95
8.0.110.0020.00517.01
8.0.100.0040.00417.27
8.0.90.0000.00816.96
8.0.80.0110.00517.13
8.0.70.0030.00517.06
8.0.60.0070.00017.10
8.0.50.0030.00517.02
8.0.30.0110.00817.32
8.0.20.0030.02417.32
8.0.10.0040.00417.32
8.0.00.0070.01217.03
7.4.330.0050.00015.55
7.4.320.0000.00716.93
7.4.300.0030.00316.83
7.4.290.0070.00016.96
7.4.280.0040.00416.77
7.4.270.0000.00816.83
7.4.260.0040.00416.89
7.4.250.0040.00416.75
7.4.240.0040.00316.84
7.4.230.0040.00416.75
7.4.220.0030.00516.93
7.4.210.0050.01216.77
7.4.200.0000.00816.86
7.4.160.0090.00816.77
7.4.140.0040.01417.86
7.4.130.0060.01216.83
7.4.120.0030.01616.88
7.4.110.0090.00916.71
7.4.100.0140.01016.89
7.4.90.0140.00416.88
7.4.80.0070.01119.39
7.4.70.0040.01816.85
7.4.60.0030.01316.68
7.4.50.0070.01016.43
7.4.40.0060.01216.66
7.4.10.0090.00915.17
7.4.00.0090.01015.09
7.3.330.0060.00013.32
7.3.320.0000.00713.40
7.3.310.0070.00016.44
7.3.300.0040.00416.55
7.3.290.0000.00716.55
7.3.280.0080.00916.56
7.3.260.0090.01116.72
7.3.240.0090.01116.66
7.3.230.0130.00416.61
7.3.210.0100.00716.56
7.3.200.0100.00716.45
7.3.190.0030.01416.83
7.3.180.0110.00516.60
7.3.170.0030.01416.72
7.3.160.0140.00416.62
7.3.130.0060.01015.23
7.3.120.0090.00915.26
7.3.110.0000.01915.09
7.3.100.0040.01115.12
7.3.90.0060.01314.73
7.3.80.0040.01115.25
7.3.70.0100.00315.14
7.3.60.0040.00814.77
7.3.50.0060.00315.03
7.3.40.0090.00614.88
7.3.30.0040.01115.06
7.3.20.4480.00715.73
7.3.10.3400.00715.78
7.3.00.1930.01115.74
7.2.330.0120.00516.86
7.2.320.0110.01116.70
7.2.310.0070.01116.92
7.2.300.0070.01116.87
7.2.290.0110.00616.91
7.2.260.0060.01315.20
7.2.250.0120.00615.54
7.2.240.0040.00815.07
7.2.230.0100.00715.22
7.2.220.0060.01215.43
7.2.210.0040.01215.06
7.2.200.0120.00415.29
7.2.190.0090.00615.17
7.2.180.0070.00315.36
7.2.170.0040.01115.30
7.2.160.0130.00015.29
7.2.150.2110.00816.12
7.2.140.2960.00816.20
7.2.130.2360.01116.08
7.2.120.1820.00716.14
7.2.110.2050.00715.96
7.2.100.2570.01016.03
7.2.90.2070.00816.30
7.2.80.2380.01116.23
7.2.70.1830.00516.10
7.2.60.1880.00716.18
7.2.50.1900.00716.08
7.2.40.1930.00216.20
7.2.30.2040.00816.17
7.2.20.2200.01216.10
7.2.10.1820.01116.18
7.2.00.1860.01116.18
7.1.330.0070.00716.12
7.1.320.0040.00716.24
7.1.310.0030.00616.21
7.1.300.0000.00915.75
7.1.290.0040.00415.77
7.1.280.0120.00315.80
7.1.270.0080.00416.04
7.1.260.0030.00616.00
7.1.250.2490.00615.02
7.1.240.0000.01316.20
7.1.230.0120.00316.03
7.1.220.0080.00315.82
7.1.210.0030.01016.01
7.1.200.0040.00716.04
7.1.190.0090.00616.17
7.1.180.0060.00315.99
7.1.170.0040.01115.75
7.1.160.0080.00416.15
7.1.150.0060.01215.83
7.1.140.0060.01215.94
7.1.130.0060.00915.69
7.1.120.0130.00016.00
7.1.110.0000.00915.92
7.1.100.0030.00915.80
7.1.90.0040.01116.07
7.1.80.0080.00815.89
7.1.70.0030.01315.99
7.1.60.0060.00915.85
7.1.50.0040.01116.16
7.1.40.0110.00316.07
7.1.30.0090.00315.76
7.1.20.0030.01015.77
7.1.10.0030.01015.86
7.1.00.0000.01415.83

preferences:
31.03 ms | 403 KiB | 5 Q