3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This is the body field of my database article table. $body * "<p style="margin:20px auto; font-size:20px;">每天都有好心情,我真的很开心 Very happy! oh yes</p>" * * */ $body = '<p style="margin:20px auto; font-size:20px;">每天都有好心情,我真的很开心 Very happy! oh yes</p>'; $str = htmlspecialchars_decode($body); $keywords = [ 0=>['id'=>1,'slug'=>'好心情','url'=>'https://www.example.com/goodMood'], 1=>['id'=>2,'slug'=>'开心','url'=>'https://www.example.com/happy'], 2=>['id'=>3,'slug'=>'happy','url'=>'https://www.example.com/happy1'], ]; //I want to convert to this format: $result = '<p style="margin:20px auto; font-size:20px;">每天都有<a href="https://www.example.com/goodMood">好心情</a>,我真的很<a href="https://www.example.com/happy">开心</a> Very <a href="https://www.example.com/happy1">happy</a>! oh yes</p>'; $reps = array_combine(array_column($keywords, 'slug'), array_map(function ($k) { return '<a href="' . $k['url'] .'">' . $k['slug'] . '</a>'; }, $keywords )); $newstr = strtr($str, $reps); echo "$newstr\n$result";

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.5.10.0040.00516.73
8.5.00.0160.00519.96
8.4.150.0020.00014.05
8.4.140.0140.00917.37
8.4.130.0120.00717.55
8.4.120.0140.00620.48
8.4.110.0130.00822.39
8.4.100.0060.00517.80
8.4.90.0140.00918.84
8.4.80.0080.00719.53
8.4.70.0090.01017.75
8.4.60.0100.01118.93
8.4.50.0080.01220.51
8.4.40.0110.00017.43
8.4.30.0030.01719.50
8.4.20.0130.00720.41
8.4.10.0220.00717.73
8.3.280.0110.01018.34
8.3.270.0140.00516.51
8.3.260.0130.00516.98
8.3.250.0110.00619.07
8.3.240.0110.00816.22
8.3.230.0060.00716.66
8.3.220.0070.01118.83
8.3.210.0040.00421.04
8.3.200.0140.00516.52
8.3.190.0130.00617.19
8.3.180.0130.00518.36
8.3.170.0110.00717.07
8.3.160.0130.00718.48
8.3.150.0050.00318.60
8.3.140.0240.00317.67
8.3.130.0210.00317.34
8.3.120.0200.00317.48
8.3.110.0190.00618.68
8.3.100.0240.00717.50
8.3.90.0190.00821.69
8.3.80.0220.00617.74
8.3.70.0260.00217.47
8.3.60.0160.01017.24
8.3.50.0170.00917.40
8.3.40.0210.00618.00
8.3.30.0210.00617.94
8.3.20.0180.00418.31
8.3.10.0150.00719.58
8.3.00.0090.00519.06
8.2.290.0050.00420.58
8.2.280.0110.00718.32
8.2.270.0130.00617.06
8.2.260.0170.00616.43
8.2.250.0180.00517.30
8.2.240.0230.00617.70
8.2.230.0150.00919.44
8.2.220.0150.01020.38
8.2.210.0180.00621.68
8.2.200.0150.00817.62
8.2.190.0230.00716.57
8.2.180.0210.00917.19
8.2.170.0200.01220.40
8.2.160.0200.00419.12
8.2.150.0160.00320.88
8.2.140.0140.01121.06
8.2.130.0230.00221.79
8.2.120.0200.00619.16
8.2.110.0180.00719.80
8.2.100.0170.00817.63
8.2.90.0160.00819.07
8.2.80.0180.00618.01
8.2.70.0170.00817.66
8.2.60.0150.00917.48
8.2.50.0190.00517.59
8.2.40.0140.00718.57
8.2.30.0160.00618.42
8.2.20.0170.00517.73
8.2.10.0100.01217.69
8.2.00.0140.00917.54
8.1.330.0130.00621.90
8.1.320.0130.00716.19
8.1.310.0220.00817.17
8.1.300.0190.01016.74
8.1.290.0190.00423.39
8.1.280.0210.00620.89
8.1.270.0160.00918.13
8.1.260.0210.00321.83
8.1.250.0120.01222.67
8.1.240.0210.00518.17
8.1.230.0240.00317.61
8.1.220.0160.00417.48
8.1.210.0150.00718.01
8.1.200.0110.00817.25
8.1.190.0190.00317.23
8.1.180.0120.00917.63
8.1.170.0170.00217.46
8.1.160.0150.00517.99
8.1.150.0150.00318.05
8.1.140.0170.00219.67
8.1.130.0180.00518.76
8.1.120.0140.00717.40
8.1.110.0180.00417.24
8.1.100.0150.00817.39
8.1.90.0100.00217.29
8.1.80.0070.00517.38
8.1.70.0160.00517.29
8.1.60.0160.00717.52
8.1.50.0150.01017.20
8.1.40.0170.00617.48
8.1.30.0190.00417.61
8.1.20.0140.00717.52
8.1.10.0210.00217.40
8.1.00.0160.00817.32
8.0.300.0180.00517.62
8.0.290.0180.00416.70
8.0.280.0170.00517.48
8.0.270.0160.00616.89
8.0.260.0130.00817.48
8.0.250.0120.01016.81
8.0.240.0190.00216.87
8.0.230.0130.00516.73
8.0.220.0180.00316.79
8.0.210.0140.00816.73
8.0.200.0110.01016.74
8.0.190.0150.00416.71
8.0.180.0130.00816.64
8.0.170.0190.00316.78
8.0.160.0170.00616.72
8.0.150.0190.00416.69
8.0.140.0180.00316.66
8.0.130.0150.00614.96
8.0.120.0150.00416.65
8.0.110.0170.00416.67
8.0.100.0210.00416.67
8.0.90.0110.01116.58
8.0.80.0150.00916.73
8.0.70.0150.00716.57
8.0.60.0140.00816.68
8.0.50.0170.00516.62
8.0.30.0130.00916.99
8.0.20.0200.00217.08
8.0.10.0120.00516.86
8.0.00.0130.00816.86
7.4.330.0080.00415.86
7.4.320.0130.00816.41
7.4.300.0140.00616.36
7.4.290.0180.00416.45
7.4.280.0130.00516.42
7.4.270.0140.00816.33
7.4.260.0180.00516.36
7.4.250.0200.00316.38
7.4.240.0130.00816.32
7.4.230.0110.00716.40
7.4.220.0120.00616.43
7.4.210.0110.00816.45
7.4.200.0160.00316.28
7.4.190.0160.01616.32
7.4.180.0180.01516.11
7.4.160.0150.00716.46
7.4.150.0290.00416.27
7.4.140.0110.01117.58
7.4.130.0150.00916.38
7.4.120.0140.00816.52
7.4.110.0130.01016.37
7.4.100.0150.00816.27
7.4.90.0200.00916.29
7.4.80.0160.01117.81
7.4.70.0210.00416.42
7.4.60.0190.00616.40
7.4.50.0130.00816.29
7.4.40.0240.00316.43
7.4.30.0260.00716.27
7.4.20.0270.00616.23
7.4.10.0270.00516.16
7.4.00.0160.00715.30
7.3.330.0120.00714.61
7.3.320.0130.00614.71
7.3.310.0130.00716.17
7.3.300.0180.00216.06
7.3.290.0140.00516.19
7.3.280.0090.01116.35
7.3.270.0250.00815.88
7.3.260.0180.00616.38
7.3.250.0390.00015.90
7.3.240.0160.00616.34
7.3.230.0160.00916.14
7.3.220.0300.00416.18
7.3.210.0170.00916.08
7.3.200.0200.00516.50
7.3.190.0150.00116.34
7.3.180.0100.00516.28
7.3.170.0090.00716.36
7.3.160.0110.00716.34
7.3.150.0170.00016.15
7.3.140.0120.00316.01
7.3.130.0220.00015.94
7.3.120.0200.00915.44
7.3.110.0190.00515.35
7.3.100.0180.00715.41
7.3.90.0190.00515.58
7.3.80.0140.00915.28
7.3.70.0200.00215.25
7.3.60.0130.01015.51
7.3.50.0150.01015.50
7.3.40.0160.00615.64
7.3.30.0150.00715.39
7.3.20.0190.00617.19
7.3.10.0150.00717.40
7.3.00.0210.00317.31
7.2.340.0290.00316.30
7.2.330.0190.00616.26
7.2.320.0150.01216.15
7.2.310.0180.00616.43
7.2.300.0190.00516.44
7.2.290.0200.00416.31
7.2.280.0230.00816.08
7.2.270.0300.00415.97
7.2.260.0260.00716.03
7.2.250.0150.01015.45
7.2.240.0170.01015.61
7.2.230.0180.00515.49
7.2.220.0130.00715.74
7.2.210.0130.00615.60
7.2.200.0120.01015.79
7.2.190.0190.00215.69
7.2.180.0160.00615.67
7.2.170.0130.00815.60
7.2.160.0280.00416.30
7.2.150.0270.00918.20
7.2.140.0330.00418.13
7.2.130.0280.01417.79
7.2.120.0300.00318.08
7.2.110.0460.00916.58
7.2.100.0580.00916.42
7.2.90.0520.00516.28
7.2.80.0490.00316.29
7.2.70.0490.00816.53
7.2.60.0480.00916.45
7.2.50.0510.00516.57
7.2.40.0490.00516.48
7.2.30.0450.00716.63
7.2.20.0510.00816.65
7.2.10.0390.00916.59
7.2.00.0440.01016.46
7.1.330.0140.00816.33
7.1.320.0140.00716.47
7.1.310.0190.00316.50
7.1.300.0140.00816.47
7.1.290.0150.00516.35
7.1.280.0150.00816.53
7.1.270.0150.00716.30
7.1.260.0140.00616.33
7.1.250.0210.00717.05
7.1.240.0220.00417.16
7.1.230.0620.00715.39
7.1.220.0800.00515.43
7.1.210.0430.01115.31
7.1.200.0550.00215.36
7.1.190.0370.00815.21
7.1.180.0430.00915.62
7.1.170.0420.00915.41
7.1.160.0440.00515.37
7.1.150.0380.00915.60
7.1.140.0410.00815.45
7.1.130.0340.01115.53
7.1.120.0390.00815.24
7.1.110.0550.00415.31
7.1.100.0440.00615.28
7.1.90.0480.00515.42
7.1.80.0340.01015.67
7.1.70.0370.00815.25
7.1.60.0440.01024.29
7.1.50.0470.00724.51
7.1.40.0420.01324.30
7.1.30.0540.00524.51
7.1.20.0490.00624.36
7.1.10.0340.01015.43
7.1.00.0470.00215.46
7.0.330.0200.00816.64
7.0.320.0200.00817.03
7.0.310.0190.00616.94
7.0.300.0270.00616.50
7.0.290.0300.00316.58
7.0.280.0190.00616.54
7.0.270.0170.00917.01
7.0.260.0230.00016.91
7.0.250.0270.00016.86
7.0.240.0230.00016.81
7.0.230.0250.00317.05
7.0.220.0210.01016.92
7.0.210.0280.00416.93
7.0.200.0190.00616.91
7.0.190.0140.00816.95
7.0.180.0210.00416.79
7.0.170.0250.00016.73
7.0.160.0220.00616.71
7.0.150.0200.00916.55
7.0.140.0180.01016.61
7.0.130.0220.00916.91
7.0.120.0140.01416.98
7.0.110.0200.00816.76
7.0.100.0180.00716.95
7.0.90.0210.00816.82
7.0.80.0240.00716.81
7.0.70.0220.00616.70
7.0.60.0190.01016.57
7.0.50.0170.01116.37
7.0.40.0190.01016.94
7.0.30.0210.00716.59
7.0.20.0170.00716.98
7.0.10.0210.00616.65
7.0.00.0200.00416.82
5.6.400.0210.00315.95
5.6.390.0160.00315.76
5.6.380.0130.00714.93
5.6.370.0160.00415.93
5.6.360.0150.01515.89
5.6.350.0300.00016.02
5.6.340.0270.00315.94
5.6.330.0190.00415.73
5.6.320.0270.00015.57
5.6.310.0360.00315.83
5.6.300.0210.00715.59
5.6.290.0260.00315.77
5.6.280.0260.00315.61
5.6.270.0250.00415.86
5.6.260.0190.00715.75
5.6.250.0190.00615.70
5.6.240.0180.01315.95
5.6.230.0220.00915.74
5.6.220.0150.00915.86
5.6.210.0190.01015.59
5.6.200.0150.01515.84
5.6.190.0240.00316.02
5.6.180.0120.01215.98
5.6.170.0230.00315.73
5.6.160.0090.00615.84
5.6.150.0220.00615.96
5.6.140.0260.00315.98
5.6.130.0210.00315.98
5.6.120.0180.00615.94
5.6.110.0210.00315.90
5.6.100.0180.01115.89
5.6.90.0300.00015.64
5.6.80.0230.00615.75
5.6.70.0140.01415.90
5.6.60.0190.00915.82
5.6.50.0210.00715.80
5.6.40.0120.01615.74
5.6.30.0260.00315.77
5.6.20.0240.00315.92
5.6.10.0230.00315.87
5.6.00.0140.00915.80

preferences:
42.4 ms | 403 KiB | 5 Q