3v4l.org

run code in 300+ PHP versions simultaneously
<?php $indicator = '<span class="required">*</span>'; echo "** Before **\n"; var_dump( $indicator ); function replace_glyth( $haystack, $replacement ) { return str_replace( '*', $replacement, $haystack ); } // Replacing the asterisk. echo "\n\n** Direct replacement **\n"; var_dump( replace_glyth( $indicator, 'required' ) ); function replace_translatable_glyth( $haystack, $replacement ) { $pattern = '/(<span class="required">)(.*)(<\/span>)/i'; $replacement = sprintf( '${1}%s${3}', $replacement ); $new = preg_replace( $pattern, $replacement, $haystack ); return $new; $pattern = '/<span class="required">(?<glyth>.*)<\/span>/i'; preg_match( $pattern, $haystack, $matches ); var_dump( $matches ); // No glyth found. if ( empty( $matches['glyth' ] ) ) { return $haystack; } return str_replace( $matches['glyth'], $replacement, $haystack ); } // Since the asterisk is translatable ... echo "\n\n** Pattern to adjust for translatable glyth **\n"; var_dump( replace_translatable_glyth( $indicator, '**required**' ) );

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.10.0060.00921.96
8.3.140.0000.01518.93
8.3.130.0060.00318.51
8.3.120.0030.00620.75
8.3.110.0080.00020.94
8.3.100.0070.00318.43
8.3.90.0110.00716.98
8.3.80.0060.00318.56
8.3.70.0160.00618.29
8.3.60.0070.01018.56
8.3.50.0070.01120.47
8.3.40.0070.00720.29
8.3.30.0000.01518.74
8.3.20.0080.00024.18
8.3.10.0090.00024.66
8.3.00.0030.00526.16
8.2.260.0180.00016.31
8.2.250.0070.00716.69
8.2.240.0160.00317.18
8.2.230.0040.00422.58
8.2.220.0000.01924.06
8.2.210.0000.00826.77
8.2.200.0080.00316.63
8.2.190.0070.01016.88
8.2.180.0150.00625.92
8.2.170.0140.01019.13
8.2.160.0030.01022.96
8.2.150.0030.00525.66
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0080.00019.95
8.2.110.0060.00320.57
8.2.100.0040.00817.84
8.2.90.0040.00417.75
8.2.80.0040.00418.92
8.2.70.0060.00317.75
8.2.60.0000.00917.68
8.2.50.0080.00018.05
8.2.40.0040.00418.09
8.2.30.0040.00418.01
8.2.20.0040.00419.17
8.2.10.0000.00718.07
8.2.00.0040.00419.24
8.1.310.0030.00616.60
8.1.300.0030.00617.67
8.1.290.0030.00618.88
8.1.280.0080.00825.92
8.1.270.0040.00424.66
8.1.260.0070.00726.35
8.1.250.0050.00328.09
8.1.240.0040.00419.01
8.1.230.0080.00317.83
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0030.00617.36
8.1.190.0000.00817.35
8.1.180.0080.00018.10
8.1.170.0040.00417.62
8.1.160.0040.00419.07
8.1.150.0040.00418.76
8.1.140.0080.00017.57
8.1.130.0040.00418.77
8.1.120.0030.00417.46
8.1.110.0030.00617.54
8.1.100.0110.00017.48
8.1.90.0110.00617.45
8.1.80.0150.00417.52
8.1.70.0160.00017.42
8.1.60.0170.00317.70
8.1.50.0090.00917.61
8.1.40.0160.00317.70
8.1.30.0160.00317.84
8.1.20.0140.00417.82
8.1.10.0160.00217.65
8.1.00.0120.00617.64
8.0.300.0080.00018.77
8.0.290.0000.00716.75
8.0.280.0030.00318.45
8.0.270.0000.00716.91
8.0.260.0030.00318.37
8.0.250.0000.00717.07
8.0.240.0080.00017.07
8.0.230.0130.00316.99
8.0.220.0160.00016.97
8.0.210.0050.01016.84
8.0.200.0050.01117.13
8.0.190.0100.00717.01
8.0.180.0180.00016.86
8.0.170.0130.00316.89
8.0.160.0130.00317.04
8.0.150.0160.00016.84
8.0.140.0090.00616.92
8.0.130.0060.00317.07
8.0.120.0070.00716.87
8.0.110.0080.00616.88
8.0.100.0150.00016.96
8.0.90.0090.00616.92
8.0.80.0110.00416.97
8.0.70.0050.01116.79
8.0.60.0100.00516.83
8.0.50.0100.00516.98
8.0.30.0070.00716.84
8.0.20.0090.00617.04
8.0.10.0000.01517.08
7.4.330.0030.00315.55
7.4.320.0030.00316.69
7.4.300.0140.00316.74
7.4.290.0120.00616.64
7.4.280.0170.00016.79
7.4.270.0130.00316.57
7.4.260.0120.00516.82
7.4.250.0180.00016.76
7.4.240.0120.00416.79
7.4.230.0150.00216.70
7.4.220.0150.00016.69
7.4.210.0050.01016.76
7.4.200.0120.00316.84
7.4.190.0140.00016.82
7.4.180.0100.00516.61
7.4.160.0040.00916.65
7.4.150.0110.00316.77
7.4.140.0080.00516.74
7.4.130.0130.00016.78
7.4.120.0080.00616.75
7.4.110.0140.00016.75
7.4.100.0070.00716.87
7.4.90.0050.00716.75
7.4.80.0040.00416.83
7.4.70.0110.00016.80
7.4.60.0040.00416.59
7.4.50.0090.00016.76
7.4.40.0000.00916.55
7.4.30.0040.00416.72
7.4.20.0030.00816.59
7.4.10.0070.00416.71
7.4.00.0000.00916.65

preferences:
31.24 ms | 403 KiB | 5 Q