3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data1 = '"slug,1", slug 2, test, "slug, 3", " ", "", ",",'; $data2 = 'foo, bar'; $data3 = 'foo, bar, "'; function is_valid_plugin_slug($slug) { return trim($slug, ", \t\n\r\0\x0B") !== ''; } function str_getcsv_augmented($data) { $plugins = str_getcsv( str_replace('""', '', $data ) ); return array_filter($plugins, 'is_valid_plugin_slug'); } function extract_required_plugins_from_header($required) { if (!$required || (substr_count($required, '"') < 2)) { return $required ? array_filter(array_map('trim', explode(',', str_replace('"', '', $required)))) : []; } $required = str_replace('""', '', $required); preg_match_all('#"([^"]+)"#', $required, $matches); $slugs = array_filter(array_map('trim', explode(',', strtr($required, array_fill_keys($matches[0], ''))))); return array_merge(array_filter($matches[1], 'is_valid_plugin_slug'), $slugs); } echo "Bare str_getcsv:\n"; var_dump( str_getcsv( $data1 ), str_getcsv( $data2 ), str_getcsv( $data3 ) ); echo "\n\nstr_getcsv with filtering:\n"; var_dump( str_getcsv_augmented( $data1 ), str_getcsv_augmented( $data2 ), str_getcsv_augmented( $data3 ) ); echo "\n\nextract_required_plugins_from_header:\n"; var_dump( extract_required_plugins_from_header( $data1 ), extract_required_plugins_from_header( $data2 ), extract_required_plugins_from_header( $data3 ) );

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.20.0130.00320.68
8.4.10.0050.00518.69
8.3.150.0130.00720.47
8.3.140.0070.01116.92
8.3.130.0100.01018.49
8.3.120.0030.00620.70
8.3.110.0040.00416.77
8.3.100.0110.00424.06
8.3.90.0190.00016.82
8.3.80.0060.00318.43
8.3.70.0120.00316.75
8.3.60.0080.00816.50
8.3.50.0100.00716.49
8.3.40.0100.00718.92
8.3.30.0090.00618.96
8.3.20.0050.00324.18
8.3.10.0060.00324.66
8.3.00.0040.00426.16
8.2.270.0070.00317.28
8.2.260.0030.00616.69
8.2.250.0060.00317.13
8.2.240.0000.00917.24
8.2.230.0070.01020.94
8.2.220.0030.00637.54
8.2.210.0030.00526.77
8.2.200.0040.00416.63
8.2.190.0070.01116.75
8.2.180.0070.00725.92
8.2.170.0060.01319.02
8.2.160.0070.00722.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00320.89
8.2.110.0060.00320.22
8.2.100.0040.00818.16
8.2.90.0030.00617.88
8.2.80.0060.00319.09
8.2.70.0040.00417.75
8.2.60.0050.00517.84
8.2.50.0030.00517.88
8.2.40.0030.00717.87
8.2.30.0070.00018.11
8.2.20.0070.00018.23
8.2.10.0080.00019.39
8.2.00.0000.00719.40
8.1.310.0080.00016.86
8.1.300.0040.00420.25
8.1.290.0070.00318.88
8.1.280.0090.01225.92
8.1.270.0060.01620.79
8.1.260.0090.00026.35
8.1.250.0000.00928.09
8.1.240.0030.00622.65
8.1.230.0040.01117.82
8.1.220.0050.00317.74
8.1.210.0050.00318.77
8.1.200.0040.00417.60
8.1.190.0030.00617.48
8.1.180.0050.00318.10
8.1.170.0050.00317.62
8.1.160.0070.00019.08
8.1.150.0040.00418.88
8.1.140.0040.00418.85
8.1.130.0030.00320.28
8.1.120.0000.00717.64
8.1.110.0070.00017.66
8.1.100.0000.00817.66
8.1.90.0050.00317.52
8.1.80.0080.00017.62
8.1.70.0000.00717.64
8.1.60.0000.00917.77
8.1.50.0030.00617.71
8.1.40.0030.01017.63
8.1.30.0060.00317.80
8.1.20.0040.00417.84
8.1.10.0030.00617.77
8.1.00.0040.00417.68
8.0.300.0000.00818.77
8.0.290.0000.00717.00
8.0.280.0030.00318.53
8.0.270.0040.00418.10
8.0.260.0030.00318.68
8.0.250.0050.00217.13
8.0.240.0000.00817.14
8.0.230.0000.00717.09
8.0.220.0000.00717.03
8.0.210.0050.00216.93
8.0.200.0000.00817.14
8.0.190.0030.00617.19
8.0.180.0040.00416.96
8.0.170.0000.00816.98
8.0.160.0050.00316.97
8.0.150.0050.00317.03
8.0.140.0070.00017.02
8.0.130.0060.00313.48
8.0.120.0080.00016.95
8.0.110.0040.00417.11
8.0.100.0000.00817.09
8.0.90.0000.00716.93
8.0.80.0030.00617.10
8.0.70.0000.00817.02
8.0.60.0000.00717.11
8.0.50.0000.00917.13
8.0.30.0030.00516.94
8.0.20.0000.00816.98
8.0.10.0030.00517.03
8.0.00.0000.00917.22
7.4.330.0000.00615.55
7.4.320.0000.00616.75
7.4.300.0070.00016.75
7.4.290.0060.00316.70
7.4.280.0050.00316.69
7.4.270.0040.00416.74
7.4.260.0050.00013.54
7.4.250.0030.00616.78
7.4.240.0040.00416.66
7.4.230.0070.00016.66
7.4.220.0000.00816.54
7.4.210.0090.00016.56
7.4.200.0030.00616.88
7.4.190.0000.00816.91
7.4.180.0050.00316.90
7.4.160.0030.00716.63
7.4.150.0060.00316.53
7.4.140.0000.00716.86
7.4.130.0030.00516.75
7.4.120.0000.00816.72
7.4.110.0040.00416.75
7.4.100.0040.00416.66
7.4.90.0000.00816.80
7.4.80.0030.00416.96
7.4.70.0080.00016.88
7.4.60.0000.00716.85
7.4.50.0040.00416.78
7.4.40.0030.00516.59
7.4.30.0030.00516.51
7.4.20.0070.00016.61
7.4.10.0040.00416.74
7.4.00.0000.00816.48
7.3.330.0000.00816.49
7.3.320.0000.00613.23
7.3.310.0030.00516.37
7.3.300.0000.00916.38
7.3.290.0000.00716.47
7.3.280.0000.00716.33
7.3.270.0040.00416.30
7.3.260.0040.00416.39
7.3.250.0030.00616.48
7.3.240.0040.00416.49
7.3.230.0000.00916.34
7.3.220.0040.00416.46
7.3.210.0080.00016.40
7.3.200.0040.00416.41
7.3.190.0080.00316.46
7.3.180.0000.00816.30
7.3.170.0040.00216.46
7.3.160.0000.00816.32
7.3.150.0030.00316.32
7.3.140.0040.00416.30
7.3.130.0080.00016.35
7.3.120.0000.00816.37
7.3.110.0040.00416.35
7.3.100.0050.00316.35
7.3.90.0000.00716.72
7.3.80.0030.00316.50
7.3.70.0040.00416.50
7.3.60.0030.00516.55
7.3.50.0040.00316.63
7.3.40.0030.00516.61
7.3.30.0040.00416.40
7.3.20.0030.00516.60
7.3.10.0040.00416.54
7.3.00.0040.00416.42

preferences:
31.93 ms | 403 KiB | 5 Q