3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'Testing giving dancing 喝 喝 passing 制图 giving 跑步 吃'; // split by a space into an array $explosion = explode(' ', $string); $normalWords = []; $chineseWords = []; // loop through the array foreach ($explosion as $debris) { // if not normal alphabet characters if (!preg_match('#[a-zA-Z]+#', $debris) && !in_array($debris, $chineseWords)) { // add to chinese words array if not already in the array $chineseWords[] = $debris; } elseif (preg_match('#[a-zA-Z]+#', $debris) && !in_array($debris, $normalWords)) { // add to normal words array if not already in the array $normalWords[] = $debris; } } // reverse the chinese characters like you wanted $chineseWords = array_reverse($chineseWords); // Piece it all back together $string = implode(' ', $normalWords) . ' ' . implode(' ', $chineseWords); // and output echo $string;

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.0180.00416.75
8.3.50.0070.00716.45
8.3.40.0150.00318.96
8.3.30.0030.01218.80
8.3.20.0030.00620.90
8.3.10.0030.00622.05
8.3.00.0080.00023.65
8.2.180.0120.00618.55
8.2.170.0130.00719.09
8.2.160.0170.00022.96
8.2.150.0060.00325.66
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0050.00226.16
8.2.110.0050.00520.99
8.2.100.0060.00618.03
8.2.90.0080.00018.28
8.2.80.0040.00420.54
8.2.70.0040.00417.75
8.2.60.0040.00417.88
8.2.50.0050.00818.70
8.2.40.0130.00020.03
8.2.30.0090.00618.88
8.2.20.0020.00618.90
8.2.10.0100.00219.43
8.2.00.0080.00619.42
8.1.280.0040.01125.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0090.00028.09
8.1.240.0060.00622.14
8.1.230.0080.00421.00
8.1.220.0000.00817.79
8.1.210.0080.00018.86
8.1.200.0060.00317.47
8.1.190.0040.00417.53
8.1.180.0080.00518.81
8.1.170.0110.00319.09
8.1.160.0110.00219.18
8.1.150.0070.00519.28
8.1.140.0090.00420.17
8.1.130.0060.00619.86
8.1.120.0050.00818.53
8.1.110.0090.00418.51
8.1.100.0080.00418.10
8.1.90.0060.00618.56
8.1.80.0050.00718.51
8.1.70.0070.00618.53
8.1.60.0070.00618.62
8.1.50.0090.00318.55
8.1.40.0030.00918.56
8.1.30.0040.00918.58
8.1.20.0070.00418.71
8.1.10.0080.00518.54
8.1.00.0060.00718.58
8.0.300.0040.00420.02
8.0.290.0050.00316.88
8.0.280.0060.00619.01
8.0.270.0110.00018.84
8.0.260.0100.00119.80
8.0.250.0070.00218.31
8.0.240.0070.00418.32
8.0.230.0070.00418.24
8.0.220.0050.00518.28
8.0.210.0030.00818.25
8.0.200.0100.00318.26
8.0.190.0040.00718.32
8.0.180.0050.00718.27
8.0.170.0070.00418.29
8.0.160.0060.00518.27
8.0.150.0030.00718.19
8.0.140.0100.00118.26
8.0.130.0070.00316.52
8.0.120.0100.00218.24
8.0.110.0040.00718.23
8.0.100.0060.00518.29
8.0.90.0090.00418.30
8.0.80.0050.00917.85
8.0.70.0050.00518.22
8.0.60.0060.00518.30
8.0.50.0070.00618.20
8.0.30.0080.00818.35
8.0.20.0070.01018.33
8.0.10.0090.00318.32
8.0.00.0110.00818.23
7.4.330.0090.00118.13
7.4.320.0080.00518.13
7.4.300.0090.00418.17
7.4.290.0100.00518.07
7.4.280.0090.00318.16
7.4.270.0110.00318.12
7.4.260.0050.00616.49
7.4.250.0070.00718.11
7.4.240.0050.00617.61
7.4.230.0100.00418.11
7.4.220.0050.00517.75
7.4.210.0100.00917.33
7.4.200.0090.00418.22
7.4.190.0120.00519.52
7.4.180.0110.00719.52
7.4.160.0180.00019.52
7.4.150.0140.00619.52
7.4.140.0130.00419.52
7.4.130.0120.00818.09
7.4.120.0090.01018.03
7.4.110.0130.00618.05
7.4.100.0130.00618.09
7.4.90.0070.01218.05
7.4.80.0130.00519.46
7.4.70.0090.01118.13
7.4.60.0110.00618.06
7.4.50.0120.00518.07
7.4.40.0140.00218.04
7.4.30.0170.00019.52
7.4.20.0130.00419.52
7.4.10.0130.00317.28
7.4.00.0080.00917.28
7.3.330.0110.00217.96
7.3.320.0110.00216.34
7.3.310.0050.00718.00
7.3.300.0090.00317.96
7.3.290.0060.01017.21
7.3.280.0070.00917.94
7.3.270.0090.00919.52
7.3.260.0150.00217.98
7.3.250.0100.01019.52
7.3.240.0150.00419.52
7.3.230.0060.01417.96
7.3.220.0190.00019.52
7.3.210.0140.00518.15
7.3.200.0090.00918.16
7.3.190.0110.00617.89
7.3.180.0080.00917.99
7.3.170.0110.00718.00
7.3.160.0100.00718.12
7.3.150.0140.00519.52
7.3.140.0190.00019.52
7.3.130.0090.00917.19
7.3.120.0140.00317.13
7.3.110.0120.00417.02
7.3.100.0100.00517.29
7.3.90.0110.00517.18
7.3.80.0080.00917.23
7.3.70.0130.00417.26
7.3.60.0090.01117.14
7.3.50.0080.01117.14
7.3.40.0070.01217.22
7.3.30.0100.00817.14
7.3.20.0140.00417.20
7.3.10.0120.00617.17
7.3.00.0090.00817.21
7.2.340.0120.00619.52
7.2.330.0070.01018.14
7.2.320.0100.00618.23
7.2.310.0100.00718.13
7.2.300.0140.00718.15
7.2.290.0080.01018.16
7.2.280.0170.00019.52
7.2.270.0150.00619.52
7.2.260.0070.01217.29
7.2.250.0090.00717.40
7.2.240.0120.00317.37
7.2.230.0130.00517.40
7.2.220.0120.00617.42
7.2.210.0130.00317.46
7.2.200.0060.01017.45
7.2.190.0090.01117.37
7.2.180.0120.00717.27
7.2.170.0160.00217.38
7.2.160.0110.00917.16
7.2.150.0210.01317.45
7.2.140.0110.00417.31
7.2.130.0100.00917.49
7.2.120.0050.01317.45
7.2.110.0060.01117.32
7.2.100.0090.00917.40
7.2.90.0120.00517.44
7.2.80.0120.00517.38
7.2.70.0110.00617.47
7.2.60.0140.00417.37
7.2.50.0090.00717.37
7.2.40.0090.00717.36
7.2.30.0120.00517.41
7.2.20.0140.00317.42
7.2.10.0130.00417.35
7.2.00.0090.00817.43

preferences:
49.96 ms | 400 KiB | 5 Q