3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reverseHebrew($text) { $words = array_reverse(explode(' ', $text)); foreach ($words as $index => $word) { if (isHebrew($word)) { $words[$index] = mbStrRev($word); } } return join(' ', $words); } function isHebrew($text) { for ($i = 0, $cnt = strlen($text); $i < $cnt; ++$i) { if (ord($text[$i]) > 127) { return true; } } return false; } function mbStrRev($string, $encoding = null) { if ($encoding === null) { $encoding = mb_detect_encoding($string); } $length = mb_strlen($string, $encoding); $reversed = ''; while ($length-- > 0) { $reversed .= mb_substr($string, $length, 1, $encoding); } return $reversed; } $name = "אַבְרָהָם"; $newName = "Alexander Manukian"; echo reverseHebrew($name);

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.0070.01116.50
8.3.60.0170.00318.43
8.3.50.0040.01118.07
8.3.40.0140.00718.92
8.3.30.0090.00618.85
8.3.20.0040.00419.46
8.3.10.0030.00521.77
8.3.00.0040.00420.71
8.2.180.0140.00718.34
8.2.170.0100.00322.96
8.2.160.0110.00422.13
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0070.00018.21
8.2.120.0050.00226.35
8.2.110.0060.00319.08
8.2.100.0080.00417.84
8.2.90.0000.00817.88
8.2.80.0040.00417.97
8.2.70.0060.00318.05
8.2.60.0040.00418.21
8.2.50.0000.00818.10
8.2.40.0040.00419.47
8.2.30.0000.00819.38
8.2.20.0000.00818.11
8.2.10.0050.00218.30
8.2.00.0050.00317.78
8.1.280.0040.01425.92
8.1.270.0080.00020.73
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0000.01022.40
8.1.230.0110.00022.11
8.1.220.0000.00717.79
8.1.210.0080.00018.77
8.1.200.0040.00417.35
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0000.00818.59
8.1.160.0070.00018.88
8.1.150.0050.00218.92
8.1.140.0030.00322.12
8.1.130.0030.00320.26
8.1.120.0030.00317.52
8.1.110.0080.00017.55
8.1.100.0070.00317.58
8.1.90.0070.00017.43
8.1.80.0040.00417.55
8.1.70.0050.00317.46
8.1.60.0000.00917.55
8.1.50.0030.00517.55
8.1.40.0060.00317.60
8.1.30.0030.00517.71
8.1.20.0020.00517.78
8.1.10.0040.00417.62
8.1.00.0030.00617.56
8.0.300.0030.00618.77
8.0.290.0080.00016.88
8.0.280.0000.00718.56
8.0.270.0000.00717.20
8.0.260.0030.00318.46
8.0.250.0080.00017.03
8.0.240.0030.00317.02
8.0.230.0030.00316.98
8.0.220.0000.00916.87
8.0.210.0000.00616.98
8.0.200.0030.00316.88
8.0.190.0050.00316.98
8.0.180.0040.00416.95
8.0.170.0000.00816.86
8.0.160.0070.00017.00
8.0.150.0000.00716.82
8.0.140.0040.00416.88
8.0.130.0030.00313.45
8.0.120.0060.00316.91
8.0.110.0060.00316.88
8.0.100.0040.00416.76
8.0.90.0000.00716.91
8.0.80.0060.01316.98
8.0.70.0040.00416.93
8.0.60.0000.00717.08
8.0.50.0040.00416.82
8.0.30.0100.00917.05
8.0.20.0090.01117.40
8.0.10.0030.00516.89
8.0.00.0100.01016.69
7.4.330.0050.00015.55
7.4.320.0030.00316.68
7.4.300.0030.00316.72
7.4.290.0000.00716.66
7.4.280.0070.00316.66
7.4.270.0000.00716.54
7.4.260.0000.00716.51
7.4.250.0070.00016.46
7.4.240.0030.00616.59
7.4.230.0070.00016.61
7.4.220.0030.00616.67
7.4.210.0060.00916.69
7.4.200.0000.00716.70
7.4.160.0090.00816.66
7.4.140.0100.00817.86
7.4.130.0160.01016.52
7.4.120.0050.01416.66
7.4.110.0150.01016.51
7.4.100.0110.00616.46
7.4.90.0030.01316.55
7.4.80.0130.00719.39
7.4.70.0060.01216.60
7.4.60.0040.01216.43
7.4.50.0040.00916.65
7.4.40.0030.01916.41
7.4.10.0120.00314.91
7.4.00.0130.00514.97
7.3.330.0000.00513.31
7.3.320.0000.00713.27
7.3.310.0000.00916.26
7.3.300.0030.00516.40
7.3.290.0030.00316.33
7.3.280.0140.00716.39
7.3.260.0090.01016.51
7.3.240.0110.00716.45
7.3.230.0100.01016.51
7.3.210.0070.01016.43
7.3.200.0140.00316.68
7.3.190.0090.01116.49
7.3.180.0140.00316.45
7.3.170.0070.01016.54
7.3.160.0130.00316.59
7.3.130.0060.01315.11
7.3.120.0090.00614.62
7.3.110.0000.01815.16
7.3.100.0070.00715.04
7.3.90.0040.01414.91
7.3.80.0070.00714.80
7.3.70.0110.00014.65
7.3.60.0030.00714.73
7.3.50.0040.00814.70
7.3.40.0070.00314.83
7.3.30.0000.01014.94
7.3.20.0060.00616.68
7.3.10.0040.00816.75
7.3.00.0090.00616.51
7.2.330.0060.01216.86
7.2.320.0110.00616.77
7.2.310.0100.02616.81
7.2.300.0160.00016.87
7.2.290.0220.00316.89
7.2.260.0100.01014.80
7.2.250.0040.01515.26
7.2.240.0060.00914.96
7.2.230.0070.01115.38
7.2.220.0090.00615.09
7.2.210.0060.00915.20
7.2.200.0030.01015.22
7.2.190.0090.00315.06
7.2.180.0070.00414.87
7.2.170.0060.00615.05
7.2.160.0110.00715.12
7.2.150.0070.00716.98
7.2.140.0060.01016.85
7.2.130.0080.00816.62
7.2.120.0030.01017.00
7.2.110.0410.00415.70
7.2.100.0410.00515.82
7.2.90.0360.00815.82
7.2.80.0410.00515.75
7.2.70.0420.00715.71
7.2.60.0120.00916.01
7.2.50.0260.00816.05
7.2.40.0500.00915.93
7.2.30.0450.00515.83
7.2.20.0370.00615.62
7.2.10.0350.01015.73
7.2.00.0340.01216.05
7.1.330.0100.00315.93
7.1.320.0060.00915.98
7.1.310.0060.01215.71
7.1.300.0070.00715.76
7.1.290.0060.00315.93
7.1.280.0070.00715.67
7.1.270.0070.00715.83
7.1.260.0070.00315.87
7.1.250.0030.01016.03
7.1.240.0070.00315.63
7.1.230.0320.00914.78
7.1.220.0360.00814.84
7.1.210.0430.00914.83
7.1.200.0420.00314.73
7.1.190.0350.01014.83
7.1.180.0280.01014.86
7.1.170.0180.00514.69
7.1.160.0530.01014.85
7.1.150.0610.00514.77
7.1.140.0380.00414.68
7.1.130.0420.00314.68
7.1.120.0310.01314.59
7.1.110.0310.01015.01
7.1.100.0330.00814.72
7.1.90.0150.01014.96
7.1.80.0360.00814.75
7.1.70.0270.01114.78
7.1.60.0420.01123.90
7.1.50.0370.00723.86
7.1.40.0350.01323.83
7.1.30.0380.01323.91
7.1.20.0450.00524.04
7.1.10.0350.01414.71
7.1.00.0330.00714.91
7.0.330.0070.00715.25
7.0.320.0030.00915.47
7.0.310.0070.00715.12
7.0.300.0000.01115.46
7.0.290.0090.00315.05
7.0.280.0040.00815.54
7.0.270.0030.00715.23
7.0.260.0000.01315.61
7.0.250.0060.00615.56
7.0.240.0000.01415.58
7.0.230.0070.00415.38
7.0.220.0060.00915.63
7.0.210.0090.00315.48
7.0.200.0070.01015.15
7.0.190.0000.00915.38
7.0.180.0060.00615.44
7.0.170.0040.00815.53
7.0.160.0130.00315.57
7.0.150.0090.00915.23
7.0.140.0110.00415.17
7.0.130.0110.00015.60
7.0.120.0070.00715.36
7.0.110.0070.00715.56
7.0.100.0160.00015.40
7.0.90.0040.01515.61
7.0.80.0130.00015.54
7.0.70.0030.01015.42
7.0.60.0060.01015.30
7.0.50.0000.01115.53
7.0.40.0080.00613.58
7.0.30.0070.00313.52
7.0.20.0090.00313.64
7.0.10.0040.00713.60
7.0.00.0070.00413.47
5.6.400.0030.01014.44
5.6.390.0000.01614.43
5.6.380.0090.00814.24
5.6.370.0070.00714.39
5.6.360.0070.01014.59
5.6.350.0060.00914.66
5.6.340.0070.00714.54
5.6.330.0100.00714.31
5.6.320.0060.00614.19
5.6.310.0050.00514.61
5.6.300.0100.00714.38
5.6.290.0070.01314.46
5.6.280.0110.00414.27
5.6.270.0080.00814.52
5.6.260.0100.00714.51
5.6.250.0090.00614.38
5.6.240.0080.01214.55
5.6.230.0030.01314.52
5.6.220.0030.01314.38
5.6.210.0080.00314.55
5.6.200.0090.00614.40
5.6.190.0000.01514.36
5.6.180.0040.00814.40
5.6.170.0040.00414.35
5.6.160.0090.00314.16
5.6.150.0040.00814.49
5.6.140.0040.00414.34
5.6.130.0000.01014.41
5.6.120.0030.00614.31
5.6.110.0040.01114.21
5.6.100.0030.01014.09
5.6.90.0090.00614.66
5.6.80.0040.00814.16
5.6.70.0030.00914.01
5.6.60.0030.01014.32
5.6.50.0060.00614.63
5.6.40.0060.00614.34
5.6.30.0060.00614.21
5.6.20.0030.01214.23
5.6.10.0030.01014.33
5.6.00.0000.01514.24

preferences:
54.99 ms | 400 KiB | 5 Q