3v4l.org

run code in 300+ PHP versions simultaneously
<?php $document = json_decode(<<<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?\\n" }, { "row": "\\f" } ], "3": [ { "row": "Some text on the third column. First row. Trevor btw." }, { "row": "\\f" } ] } 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, $columns = false): array { $columns = $columns === false ? array_keys($table) : (array)$columns; return array_map(function ($column) use ($table, $columns) { return in_array($column, $columns) ? array_map('self::regex_replace', $table[$column]) : $table[$column]; }, array_keys($table)); } public function regex_replace(array $table) { return preg_replace($this->pattern, $this->replacement, $table); } } $options = [ 'pattern' => '/Trevor/i', 'replacement' => 'Oliver', ]; $engine = new regexTextReplace($options); print_r('======= ONLY COLUMN 1 =======' . PHP_EOL . PHP_EOL); print_r($engine->apply($document, 1)); print_r(PHP_EOL . PHP_EOL . '======= COLUMNS 1 & 3 =======' . PHP_EOL . PHP_EOL); print_r($engine->apply($document, [1, 3])); print_r(PHP_EOL . PHP_EOL . '======= ALL TABLE =======' . PHP_EOL . PHP_EOL); print_r($engine->apply($document));

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.70.0120.00317.13
8.3.60.0150.00018.61
8.3.50.0120.01018.52
8.3.40.0030.01319.09
8.3.30.0120.00318.95
8.3.20.0080.00021.89
8.3.10.0040.00418.99
8.3.00.0080.00021.77
8.2.190.0150.00316.75
8.2.180.0100.00625.92
8.2.170.0060.01222.96
8.2.160.0070.00722.22
8.2.150.0070.00324.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0050.00321.19
8.2.110.0030.00619.45
8.2.100.0090.00318.16
8.2.90.0030.00618.16
8.2.80.0090.00018.00
8.2.70.0000.00818.05
8.2.60.0050.00418.03
8.2.50.0040.00419.31
8.2.40.0040.00419.60
8.2.30.0030.00620.62
8.2.20.0000.00818.29
8.2.10.0000.00819.06
8.2.00.0000.00820.04
8.1.280.0070.00725.92
8.1.270.0040.00420.91
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0050.00522.59
8.1.230.0110.00020.97
8.1.220.0040.00417.89
8.1.210.0000.00819.06
8.1.200.0070.00317.60
8.1.190.0080.00019.16
8.1.180.0030.00618.10
8.1.170.0030.00618.80
8.1.160.0040.00418.92
8.1.150.0000.00819.02
8.1.140.0070.00020.22
8.1.130.0070.00017.57
8.1.120.0030.00617.69
8.1.110.0080.00017.54
8.1.100.0000.01017.55
8.1.90.0070.00017.66
8.1.80.0000.00817.67
8.1.70.0070.00017.66
8.1.60.0040.00417.83
8.1.50.0000.00817.69
8.1.40.0040.00417.74
8.1.30.0060.00317.86
8.1.20.0050.00317.82
8.1.10.0040.00417.65
8.1.00.0050.00317.76
8.0.300.0000.00820.13
8.0.290.0100.00016.88
8.0.280.0040.00418.52
8.0.270.0070.00017.19
8.0.260.0050.00317.08
8.0.250.0040.00417.23
8.0.240.0040.00417.18
8.0.230.0040.00417.28
8.0.220.0000.00917.05
8.0.210.0080.00017.17
8.0.200.0040.00417.20
8.0.190.0030.00617.11
8.0.180.0050.00317.20
8.0.170.0000.00817.07
8.0.160.0040.00417.09
8.0.150.0040.00417.00
8.0.140.0060.00317.16
8.0.130.0030.00313.62
8.0.120.0040.00417.13
8.0.110.0030.00517.06
8.0.100.0080.00017.04
8.0.90.0040.00416.96
8.0.80.0000.01517.16
8.0.70.0040.00417.20
8.0.60.0040.00417.11
8.0.50.0040.00417.00
8.0.30.0100.01017.14
8.0.20.0080.01217.51
8.0.10.0040.00417.26
8.0.00.0130.00817.15
7.4.330.0020.00215.55
7.4.320.0030.00316.91
7.4.300.0000.00616.77
7.4.290.0050.00216.91
7.4.280.0070.00016.84
7.4.270.0060.00316.87
7.4.260.0030.00516.75
7.4.250.0070.00016.88
7.4.240.0030.00716.88
7.4.230.0040.00416.77
7.4.220.0000.00816.68
7.4.210.0090.00916.82
7.4.200.0080.00016.94
7.4.160.0080.00816.71
7.4.140.0070.01017.86
7.4.130.0100.00716.80
7.4.120.0090.00916.70
7.4.110.0080.01116.82
7.4.100.0130.01016.87
7.4.90.0170.00016.85
7.4.80.0030.01419.39
7.4.70.0030.01516.84
7.4.60.0130.00716.80
7.4.50.0090.00916.58
7.4.40.0030.01316.63
7.4.10.0100.00815.25
7.4.00.0080.00915.30
7.3.330.0000.00613.58
7.3.320.0000.00613.44
7.3.310.0070.00016.57
7.3.300.0070.00016.51
7.3.290.0000.00716.59
7.3.280.0110.00616.65
7.3.260.0110.00816.78
7.3.240.0050.01216.67
7.3.230.0060.01216.70
7.3.210.0060.01216.70
7.3.200.0120.00617.01
7.3.190.0140.00316.79
7.3.180.0030.01316.61
7.3.170.0110.00616.61
7.3.160.0100.00716.64
7.3.130.0090.00715.14
7.3.120.0090.00715.17
7.3.110.0060.01215.13
7.3.100.0030.01315.10
7.3.90.0100.00515.03
7.3.80.0090.00515.18
7.3.70.0080.00715.09
7.3.60.0050.00915.08
7.3.50.0040.00914.96
7.3.40.0050.00915.12
7.3.30.0050.00614.97
7.3.20.0060.00816.44
7.3.10.0080.00616.44
7.3.00.0070.00916.34
7.2.330.0090.00816.88
7.2.320.0110.00716.90
7.2.310.0140.00316.73
7.2.300.0030.01316.90
7.2.290.0090.00916.97
7.2.260.0120.00815.34
7.2.250.0040.01415.24
7.2.240.0090.00715.30
7.2.230.0080.00815.29
7.2.220.0040.01115.24
7.2.210.0070.00915.29
7.2.200.0050.00915.32
7.2.190.0060.00815.25
7.2.180.0060.00815.13
7.2.170.0070.01015.28
7.2.160.0050.00615.27
7.2.150.0060.00716.61
7.2.140.0080.00516.62
7.2.130.0080.00816.59
7.2.120.0100.00516.71
7.2.110.0050.01016.74
7.2.100.0050.00916.67
7.2.90.0040.01216.79
7.2.80.0070.00816.77
7.2.70.0200.01116.64
7.2.60.0060.00916.70
7.2.50.0050.00816.75
7.2.40.0080.00716.70
7.2.30.0160.00816.63
7.2.20.0080.00816.55
7.2.10.0040.00916.51
7.2.00.0060.00916.45
7.1.330.0020.01216.00
7.1.320.0070.00616.12
7.1.310.0070.00716.03
7.1.300.0050.00715.96
7.1.290.0060.00915.91
7.1.280.0050.00815.49
7.1.270.0110.00615.50
7.1.260.0050.01115.44
7.1.250.0080.00615.48
7.1.240.0020.00915.96
7.1.230.0080.00615.97
7.1.220.0030.00915.96
7.1.210.0060.00815.74
7.1.200.0050.00916.11
7.1.190.0050.00715.98
7.1.180.0040.00615.84
7.1.170.0070.00615.90
7.1.160.0050.00815.96
7.1.150.0030.00916.04
7.1.140.0080.00415.95
7.1.130.0030.01016.02
7.1.120.0030.00815.92
7.1.110.0040.00916.02
7.1.100.0070.00616.02
7.1.90.0050.00616.01
7.1.80.0050.00516.00
7.1.70.0030.00516.04
7.1.60.0070.00616.08
7.1.50.0060.01115.93
7.1.40.0060.00816.11
7.1.30.0080.00315.91
7.1.20.0060.00815.96
7.1.10.0050.00615.99
7.1.00.0040.00715.93

preferences:
15.14 ms | 401 KiB | 5 Q