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.3.130.0030.00618.31
8.3.120.0060.00318.81
8.3.110.0060.00320.94
8.3.100.0120.00418.30
8.3.90.0050.00326.77
8.3.80.0030.00619.36
8.3.70.0150.00018.55
8.3.60.0000.01418.18
8.3.50.0180.00617.94
8.3.40.0130.00318.83
8.3.30.0110.00318.61
8.3.20.0040.00419.20
8.3.10.0040.00421.73
8.3.00.0040.00420.71
8.2.250.0040.00418.32
8.2.240.0070.01118.80
8.2.230.0090.00022.58
8.2.220.0040.00824.06
8.2.210.0070.00026.77
8.2.200.0060.00318.88
8.2.190.0170.00316.58
8.2.180.0070.01118.18
8.2.170.0030.01222.96
8.2.160.0110.00420.66
8.2.150.0040.00424.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0050.00321.01
8.2.110.0030.00622.09
8.2.100.0080.00417.72
8.2.90.0000.00820.47
8.2.80.0050.00318.77
8.2.70.0040.00417.93
8.2.60.0040.00417.50
8.2.50.0080.00017.63
8.2.40.0000.00819.63
8.2.30.0040.00419.38
8.2.20.0070.00018.01
8.2.10.0000.00818.00
8.2.00.0030.00617.83
8.1.300.0070.01117.94
8.1.290.0080.00030.84
8.1.280.0080.00825.92
8.1.270.0000.01018.95
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00619.07
8.1.230.0110.00317.89
8.1.220.0050.00317.74
8.1.210.0090.00018.77
8.1.200.0000.00817.36
8.1.190.0050.00317.23
8.1.180.0030.00518.10
8.1.170.0040.00417.65
8.1.160.0000.00718.84
8.1.150.0040.00418.82
8.1.140.0030.00322.19
8.1.130.0030.00620.15
8.1.120.0030.00317.43
8.1.110.0040.00417.35
8.1.100.0000.00917.36
8.1.90.0040.00417.37
8.1.80.0060.00317.43
8.1.70.0000.00717.48
8.1.60.0000.00717.56
8.1.50.0030.00917.42
8.1.40.0000.00817.55
8.1.30.0000.00817.64
8.1.20.0000.00817.71
8.1.10.0040.00417.45
8.1.00.0000.00817.50
8.0.300.0030.00618.77
8.0.290.0040.00416.75
8.0.280.0070.00018.39
8.0.270.0080.00017.14
8.0.260.0000.00618.46
8.0.250.0030.00316.98
8.0.240.0070.00016.98
8.0.230.0000.00717.00
8.0.220.0040.00416.91
8.0.210.0030.00316.88
8.0.200.0000.00616.85
8.0.190.0030.00516.90
8.0.180.0000.00716.95
8.0.170.0090.00016.89
8.0.160.0000.00816.92
8.0.150.0100.00016.92
8.0.140.0040.00416.85
8.0.130.0000.00613.34
8.0.120.0040.00416.80
8.0.110.0030.00516.81
8.0.100.0070.00016.79
8.0.90.0000.00716.78
8.0.80.0110.00616.89
8.0.70.0040.00416.82
8.0.60.0000.00716.88
8.0.50.0000.00716.76
8.0.30.0070.01017.15
8.0.20.0150.00317.40
8.0.10.0040.00417.14
8.0.00.0080.01116.87
7.4.330.0050.00015.55
7.4.320.0000.00716.59
7.4.300.0060.00016.51
7.4.290.0000.00716.61
7.4.280.0040.00416.61
7.4.270.0000.00716.61
7.4.260.0030.00316.52
7.4.250.0080.00016.54
7.4.240.0000.00716.45
7.4.230.0000.00616.52
7.4.220.0050.00316.64
7.4.210.0070.00916.50
7.4.200.0030.00316.33
7.4.160.0120.00816.51
7.4.140.0090.01117.86
7.4.130.0100.01016.56
7.4.120.0130.00916.55
7.4.110.0060.01216.64
7.4.100.0130.00316.35
7.4.90.0100.01416.42
7.4.80.0080.01519.39
7.4.70.0130.00416.63
7.4.60.0120.00416.68
7.4.50.0030.00816.64
7.4.40.0180.00316.61
7.4.00.0090.00914.81
7.3.330.0000.00513.18
7.3.320.0030.00313.45
7.3.310.0000.00916.28
7.3.300.0030.00316.25
7.3.290.0000.00716.29
7.3.280.0030.01316.40
7.3.260.0130.00616.48
7.3.240.0120.00616.44
7.3.230.0070.01116.46
7.3.210.0040.01216.29
7.3.200.0130.01016.74
7.3.190.0150.00316.57
7.3.180.0080.00816.36
7.3.170.0090.00916.59
7.3.160.0100.01116.33
7.3.120.0080.01114.83
7.3.110.0070.01014.76
7.3.100.0100.00715.05
7.3.90.0100.00714.97
7.3.80.0000.01414.52
7.3.70.0060.00314.84
7.3.60.0040.01115.08
7.3.50.0060.00914.84
7.3.40.0120.00314.88
7.3.30.0030.01414.55
7.3.20.0060.00616.48
7.3.10.0030.00916.87
7.3.00.0120.00316.78
7.2.330.0110.00716.47
7.2.320.0060.01316.43
7.2.310.0130.00416.80
7.2.300.0130.00316.80
7.2.290.0090.00916.51
7.2.250.0060.01214.91
7.2.240.0030.01615.31
7.2.230.0080.00315.03
7.2.220.0110.00415.32
7.2.210.0030.01015.18
7.2.200.0040.01115.26
7.2.190.0100.00015.16
7.2.180.0030.00914.93
7.2.170.0060.01014.93
7.2.110.0650.01314.81
7.2.100.0930.01014.59
7.2.90.0800.00014.45
7.2.80.0710.00314.41
7.2.70.0810.00714.92
7.2.60.0780.01314.71
7.2.50.0720.00714.89
7.2.40.0690.00314.74
7.2.30.0570.01014.98
7.2.20.0740.00715.07
7.2.10.0520.01214.86
7.2.00.0660.01214.70
7.1.330.0070.00715.60
7.1.320.0000.01415.95
7.1.310.0070.00715.78
7.1.300.0060.00915.84
7.1.290.0070.00715.67
7.1.280.0090.00615.92
7.1.270.0070.00715.49
7.1.260.0080.00315.57
7.1.230.1070.00913.57
7.1.220.1400.00713.77
7.1.210.0710.00713.51
7.1.200.0860.00013.74
7.1.190.0500.01013.29
7.1.180.0600.01514.13
7.1.170.0630.01014.01
7.1.160.0670.00013.79
7.1.150.0540.01014.00
7.1.140.0590.01013.80
7.1.130.0530.00914.02
7.1.120.0570.00813.50
7.1.110.0840.00613.77
7.1.100.0640.00613.56
7.1.90.0720.00613.96
7.1.80.0530.00614.07
7.1.70.0480.00913.88
7.1.60.0620.01331.72
7.1.50.0680.01331.96
7.1.40.0610.01931.48
7.1.30.0810.00631.86
7.1.20.0660.01331.86
7.1.10.0520.00713.91
7.1.00.0640.00313.91
5.6.380.0080.00814.21

preferences:
27.64 ms | 403 KiB | 5 Q