3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "1": [ { "row": "My name is Trevor\n" }, { "row": "Can you see me?\n" }, { "row": "\f" } ], "2": [ { "row": "Hey there! Some other text.\n" }, { "row": "What is up Trevor?\n" }, { "row": "\f" } ], "3": [ { "row": "Some text on the third column. First row." }, { "row": "\f" } ] }'; $content = json_decode($json, true); class regexTextReplace { private $pattern; private $replacement; public function __construct(array $arguments) { $this->pattern = $arguments['pattern']; $this->replacement = $arguments['replacement']; } public function apply(array $table, $column = false): array { $out = array(); foreach ($table as $col => $rows) { if ($column === false || $col == $column) { $out[$col] = array_map('self::regex_replace', $rows); } else { $out[$col] = $rows; } } return $out; } public function regex_replace(array $table) { return preg_replace($this->pattern, $this->replacement, $table); } } $options = [ 'pattern' => '/Trevor/i', 'replacement' => 'Oliver', ]; $engine = new regexTextReplace($options); $columns = $engine->apply($content, 1); print_r($columns); $options = [ 'pattern' => '/Some/i', 'replacement' => 'A lot of', ]; $engine = new regexTextReplace($options); $columns = $engine->apply($content); print_r($columns);

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.0080.00817.13
8.3.50.0080.01218.28
8.3.40.0090.00619.23
8.3.30.0150.00019.09
8.3.20.0070.00021.85
8.3.10.0000.00819.27
8.3.00.0000.00721.73
8.2.180.0130.01025.92
8.2.170.0140.00022.96
8.2.160.0140.00022.23
8.2.150.0060.00324.18
8.2.140.0050.00224.66
8.2.130.0050.00226.16
8.2.120.0050.00326.16
8.2.110.0070.00421.12
8.2.100.0110.00019.41
8.2.90.0000.00819.47
8.2.80.0000.00820.63
8.2.70.0040.00417.75
8.2.60.0040.00417.75
8.2.50.0030.00517.75
8.2.40.0040.00419.73
8.2.30.0040.00420.51
8.2.20.0030.00618.17
8.2.10.0030.00519.09
8.2.00.0050.00318.19
8.1.280.0110.00725.92
8.1.270.0000.00820.87
8.1.260.0030.00526.35
8.1.250.0050.00228.09
8.1.240.0030.00722.14
8.1.230.0090.00321.03
8.1.220.0080.00017.74
8.1.210.0060.00318.91
8.1.200.0060.00617.60
8.1.190.0080.00017.60
8.1.180.0030.00619.13
8.1.170.0080.00017.62
8.1.160.0000.00719.01
8.1.150.0000.00818.90
8.1.140.0000.00720.34
8.1.130.0070.00017.66
8.1.120.0020.00517.61
8.1.110.0070.00417.61
8.1.100.0000.00717.67
8.1.90.0000.00817.63
8.1.80.0080.00017.56
8.1.70.0000.00817.64
8.1.60.0070.00317.77
8.1.50.0040.00417.69
8.1.40.0030.00617.71
8.1.30.0000.00817.90
8.1.20.0060.00317.82
8.1.10.0040.00417.65
8.1.00.0040.00417.66
8.0.300.0000.00820.36
8.0.290.0000.00817.00
8.0.280.0030.00318.43
8.0.270.0050.00217.19
8.0.260.0000.00816.94
8.0.250.0030.00517.18
8.0.240.0030.00317.03
8.0.230.0000.00717.12
8.0.220.0000.00717.05
8.0.210.0070.00017.10
8.0.200.0000.00617.13
8.0.190.0040.00417.14
8.0.180.0090.00017.07
8.0.170.0080.00317.04
8.0.160.0070.00017.07
8.0.150.0040.00417.02
8.0.140.0000.00716.98
8.0.130.0030.00313.48
8.0.120.0000.00817.09
8.0.110.0040.00417.05
8.0.100.0000.00817.05
8.0.90.0000.00816.98
8.0.80.0150.00017.07
8.0.70.0000.00816.87
8.0.60.0040.00416.91
8.0.50.0050.00216.96
8.0.30.0120.00617.27
8.0.20.0110.00817.44
8.0.10.0080.00017.20
8.0.00.0110.00716.81
7.4.330.0000.00515.55
7.4.320.0070.00016.69
7.4.300.0030.00316.76
7.4.290.0080.00016.72
7.4.280.0050.00516.76
7.4.270.0000.00916.63
7.4.260.0040.00416.80
7.4.250.0080.00016.83
7.4.240.0030.00716.94
7.4.230.0030.00316.85
7.4.220.0050.00316.89
7.4.210.0080.00616.70
7.4.200.0000.00716.81
7.4.140.0090.00917.86
7.4.130.0080.00916.81
7.4.120.0090.00916.61
7.4.110.0110.00616.76
7.4.100.0070.01416.79
7.4.90.0100.00716.75
7.4.80.0140.01019.39
7.4.70.0070.01016.70
7.4.60.0070.01016.71
7.4.50.0060.01216.72
7.4.40.0120.00616.68
7.4.00.0000.01115.27
7.3.330.0000.00513.39
7.3.320.0000.00513.53
7.3.310.0070.00016.55
7.3.300.0030.00316.42
7.3.290.0030.00416.56
7.3.280.0090.01016.51
7.3.260.0130.00616.67
7.3.240.0120.00716.69
7.3.230.0080.00816.55
7.3.210.0210.00316.74
7.3.200.0090.00916.83
7.3.190.0030.01316.91
7.3.180.0090.00616.63
7.3.170.0100.00716.78
7.3.160.0100.01016.84
7.3.50.0130.00315.01
7.3.40.0080.00514.94
7.3.30.0100.00715.00
7.3.20.0080.00916.80
7.3.10.0080.01016.87
7.3.00.0090.00816.59
7.2.330.0090.00916.81
7.2.320.0140.00416.79
7.2.310.0070.01016.85
7.2.300.0070.01016.90
7.2.290.0100.01316.75
7.2.180.0130.00615.20
7.2.170.0140.00515.21
7.2.160.0090.00515.23
7.2.150.0090.00616.95
7.2.140.0090.00517.08
7.2.130.0050.00917.00
7.2.120.0070.00617.21
7.2.110.0130.01116.96
7.2.100.0100.00917.11
7.2.90.0110.00617.11
7.2.80.0150.00817.18
7.2.70.0090.00717.27
7.2.60.0080.00817.12
7.2.50.0090.00417.09
7.2.40.0130.00817.12
7.2.30.0090.00917.16
7.2.20.0080.01017.28
7.2.10.0040.01017.15
7.2.00.0130.00817.02
7.1.280.0130.00516.03
7.1.270.0100.00815.89
7.1.260.0100.00716.02
7.1.250.0100.00816.08
7.1.240.0180.01116.09
7.1.230.0270.00416.13
7.1.220.0190.00815.92
7.1.210.0120.01015.93
7.1.200.0190.00316.01
7.1.190.0140.01015.97
7.1.180.0200.00015.79
7.1.170.0130.00715.88
7.1.160.0130.00915.80
7.1.150.0110.01115.83
7.1.140.0190.00315.78
7.1.130.0120.01215.97
7.1.120.0120.01616.04
7.1.110.0170.01015.84
7.1.100.0180.01115.92
7.1.90.0150.01015.82
7.1.80.0170.00315.90
7.1.70.0100.00915.63
7.1.60.0110.01915.96
7.1.50.0110.01316.14
7.1.40.0100.00515.86
7.1.30.0230.01116.00
7.1.20.0160.01115.98
7.1.10.0210.01215.92
7.1.00.0150.00415.80
7.0.330.0230.01415.70
7.0.320.0230.01015.44
7.0.310.0210.01015.45
7.0.300.0160.00815.25
7.0.290.0200.00415.47
7.0.280.0150.01915.58
7.0.270.0140.00915.80
7.0.260.0190.00515.69
7.0.250.0180.01815.45
7.0.240.0120.01915.45
7.0.230.0290.00815.71
7.0.220.0160.00315.48
7.0.210.0070.01815.83
7.0.200.0200.00715.36
7.0.190.0130.00915.79
7.0.180.0150.01515.72
7.0.170.0160.00615.79
7.0.160.0150.01215.76
7.0.150.0160.01615.39
7.0.140.0250.01115.78
7.0.130.0160.01615.64
7.0.120.0180.00615.74
7.0.110.0100.01715.53
7.0.100.0230.01115.67
7.0.90.0100.01415.56
7.0.80.0200.01115.63
7.0.70.0200.00515.59
7.0.60.0160.00915.61
7.0.50.0150.01215.68
7.0.40.0120.00915.87
7.0.30.0220.00315.70
7.0.20.0270.01015.83
7.0.10.0170.00215.71
7.0.00.0180.00315.70
5.6.400.0120.00213.78
5.6.390.0130.01014.12
5.6.380.0050.01914.20
5.6.370.0130.01014.09
5.6.360.0130.00414.14
5.6.350.0190.01413.94
5.6.340.0130.01314.25
5.6.330.0140.00613.73
5.6.320.0270.00413.88
5.6.310.0040.02314.38
5.6.300.0190.00313.91
5.6.290.0110.00714.00
5.6.280.0190.01213.88
5.6.270.0240.00914.29
5.6.260.0160.01013.99
5.6.250.0140.00713.91
5.6.240.0180.01314.01
5.6.230.0220.00414.00
5.6.220.0150.01514.28
5.6.210.0080.01314.03
5.6.200.0190.00313.89
5.6.190.0160.01114.31
5.6.180.0090.00913.83
5.6.170.0200.00614.04
5.6.160.0100.00714.09
5.6.150.0200.01214.13
5.6.140.0150.01513.87
5.6.130.0130.01114.27
5.6.120.0180.00913.87
5.6.110.0130.00613.92
5.6.100.0130.00714.03
5.6.90.0140.00413.88
5.6.80.0140.00713.96
5.6.70.0160.00713.75
5.6.60.0090.00914.07
5.6.50.0100.01414.08
5.6.40.0120.00613.86
5.6.30.0190.00813.92
5.6.20.0120.00614.08
5.6.10.0080.00813.70
5.6.00.0120.01213.91
5.5.380.0100.01314.05
5.5.370.0210.00314.38
5.5.360.0120.00614.08
5.5.350.0170.00014.02
5.5.340.0080.00813.99
5.5.330.0190.01614.34
5.5.320.0200.00314.24
5.5.310.0280.00314.00
5.5.300.0170.00613.85
5.5.290.0170.00413.98
5.5.280.0170.00313.80
5.5.270.0200.00813.84
5.5.260.0130.00513.92
5.5.250.0160.01013.77
5.5.240.0190.00013.76
5.5.230.0150.00813.88
5.5.220.0170.00914.06
5.5.210.0220.00413.94
5.5.200.0050.01513.76
5.5.190.0150.00214.10
5.5.180.0180.01114.24
5.5.170.0040.01613.82
5.5.160.0170.00813.74
5.5.150.0210.00313.95
5.5.140.0040.01514.19
5.5.130.0150.00714.05
5.5.120.0200.01013.81
5.5.110.0100.00714.00
5.5.100.0210.01013.80
5.5.90.0140.00713.82
5.5.80.0100.01314.13
5.5.70.0100.01314.13
5.5.60.0150.00913.84
5.5.50.0130.01013.74
5.5.40.0040.01213.89
5.5.30.0120.01213.61
5.5.20.0100.01013.75
5.5.10.0140.00514.23
5.5.00.0070.01113.89
5.4.450.0100.00013.21
5.4.440.0110.00413.21
5.4.430.0080.01013.21
5.4.420.0040.00913.21
5.4.410.0120.00713.21
5.4.400.0090.00513.21
5.4.390.0150.00513.21
5.4.380.0030.01313.21
5.4.370.0080.00913.21
5.4.360.0110.00813.21
5.4.350.0030.01013.21
5.4.340.0110.00413.21
5.4.330.0130.00013.21
5.4.320.0130.00613.21
5.4.310.0170.00413.21
5.4.300.0130.00313.21
5.4.290.0080.01213.21
5.4.280.0170.00313.21
5.4.270.0100.01013.21
5.4.260.0090.00713.21
5.4.250.0160.00013.21
5.4.240.0140.00313.21
5.4.230.0170.00613.21
5.4.220.0120.00713.21
5.4.210.0100.01113.21
5.4.200.0110.00713.21
5.4.190.0070.01313.21
5.4.180.0180.00513.21
5.4.170.0060.00613.21
5.4.160.0160.00413.21
5.4.150.0030.00913.21
5.4.140.0130.00713.21
5.4.130.0090.01213.21
5.4.120.0130.00413.21
5.4.110.0120.00613.21
5.4.100.0200.00513.21
5.4.90.0040.00813.21
5.4.80.0040.00913.21
5.4.70.0060.00613.21
5.4.60.0120.00913.21
5.4.50.0070.00713.21
5.4.40.0060.01313.21
5.4.30.0080.00813.21
5.4.20.0110.00313.21
5.4.10.0070.00713.21
5.4.00.0070.00713.21
5.3.290.0050.00913.21
5.3.280.0130.00813.21
5.3.270.0140.00413.21
5.3.260.0120.00813.21
5.3.250.0110.00613.21
5.3.240.0000.01813.21
5.3.230.0110.01113.21
5.3.220.0120.00913.21
5.3.210.0130.00313.21
5.3.200.0030.00613.21
5.3.190.0100.00313.21
5.3.180.0120.00013.21
5.3.170.0000.01213.21
5.3.160.0110.00013.21
5.3.150.0090.00613.21
5.3.140.0130.00813.21
5.3.130.0170.00613.21
5.3.120.0070.01113.21
5.3.110.0100.00613.21
5.3.100.0160.00513.21
5.3.90.0080.00613.21
5.3.80.0050.00513.21
5.3.70.0150.00413.21
5.3.60.0170.00313.21
5.3.50.0100.00313.21
5.3.40.0140.01013.21
5.3.30.0140.00313.21
5.3.20.0080.00313.21
5.3.10.0150.00013.21
5.3.00.0080.00413.21
5.2.170.0060.01113.21
5.2.160.0060.00413.21
5.2.150.0030.00713.21
5.2.140.0080.00513.21
5.2.130.0070.00713.21
5.2.120.0070.00413.21
5.2.110.0060.00313.21
5.2.100.0030.00813.21
5.2.90.0090.00213.21
5.2.80.0070.00513.21
5.2.70.0160.00313.21
5.2.60.0140.00513.21
5.2.50.0070.00313.21
5.2.40.0140.00013.21
5.2.30.0030.00613.21
5.2.20.0090.00613.21
5.2.10.0140.00013.21
5.2.00.0050.01113.21
5.1.60.0080.00013.21
5.1.50.0050.01013.21
5.1.40.0070.00213.21
5.1.30.0090.00313.21
5.1.20.0120.00213.21
5.1.10.0080.00813.21
5.1.00.0080.00513.21
5.0.50.0040.00713.21
5.0.40.0120.00213.21
5.0.30.0040.00413.21
5.0.20.0120.00313.21
5.0.10.0000.00713.21
5.0.00.0090.00213.21
4.4.90.0050.00313.21
4.4.80.0040.00213.21
4.4.70.0080.00413.21
4.4.60.0070.00313.21
4.4.50.0070.00713.21
4.4.40.0040.00413.21
4.4.30.0070.00013.21
4.4.20.0000.01013.21
4.4.10.0060.00413.21
4.4.00.0000.00713.21
4.3.110.0000.00613.21
4.3.100.0060.00613.21
4.3.90.0000.00613.21
4.3.80.0030.00213.21
4.3.70.0050.00313.21
4.3.60.0060.00013.21
4.3.50.0050.00513.21
4.3.40.0000.00913.21
4.3.30.0000.00413.21
4.3.20.0000.00413.21
4.3.10.0000.00413.21
4.3.00.0000.00513.21

preferences:
63.7 ms | 401 KiB | 5 Q