3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Converts numbers in string from western to eastern Arabic numerals. * * @param string $str Arbitrary text * @return string Text with western Arabic numerals converted into eastern Arabic numerals. */ function arabic_w2e($str) { $arabic_eastern = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $arabic_western = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); return str_replace($arabic_western, $arabic_eastern, $str); } /** * Converts numbers from eastern to western Arabic numerals. * * @param string $str Arbitrary text * @return string Text with eastern Arabic numerals converted into western Arabic numerals. */ function arabic_e2w($str) { $arabic_eastern = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $arabic_western = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); return str_replace($arabic_eastern, $arabic_western, $str); } //*/ Test $x = strval(date("H:i")); echo arabic_w2e($x); // Outputs: ١٢٣٤٥٦٧٨٩٠ // echo arabic_e2w("١٢٣٤يناير٥٦٧٨٩٠"); // Outputs: 1234567890 //*/ ?>

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.00016.48
8.3.50.0070.00716.71
8.3.40.0150.00018.97
8.3.30.0130.00618.67
8.3.20.0000.00720.35
8.3.10.0040.00421.83
8.3.00.0070.00021.85
8.2.180.0030.01218.22
8.2.170.0070.01422.96
8.2.160.0100.00320.29
8.2.150.0090.00024.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0050.00321.08
8.2.110.0090.00020.47
8.2.100.0090.00318.03
8.2.90.0000.00917.97
8.2.80.0040.00418.06
8.2.70.0030.00617.59
8.2.60.0070.00017.93
8.2.50.0000.00818.09
8.2.40.0080.00022.32
8.2.30.0050.00319.38
8.2.20.0040.00419.58
8.2.10.0070.00018.12
8.2.00.0000.00718.12
8.1.280.0140.00425.92
8.1.270.0040.00422.13
8.1.260.0000.00826.35
8.1.250.0060.00328.09
8.1.240.0110.00022.06
8.1.230.0080.00420.89
8.1.220.0030.00617.91
8.1.210.0040.00418.84
8.1.200.0040.00417.35
8.1.190.0050.00317.36
8.1.180.0040.00418.10
8.1.170.0050.00318.54
8.1.160.0000.00720.87
8.1.150.0040.00418.89
8.1.140.0060.00319.50
8.1.130.0000.00717.67
8.1.120.0040.00417.53
8.1.110.0030.00517.50
8.1.100.0000.00717.55
8.1.90.0080.00017.59
8.1.80.0050.00317.48
8.1.70.0000.00817.49
8.1.60.0070.00317.53
8.1.50.0000.00717.55
8.1.40.0000.00717.51
8.1.30.0080.00017.79
8.1.20.0040.00417.68
8.1.10.0000.00817.63
8.1.00.0060.00317.61
8.0.300.0040.00420.09
8.0.290.0050.00316.88
8.0.280.0000.00718.40
8.0.270.0030.00317.38
8.0.260.0050.00317.33
8.0.250.0030.00317.10
8.0.240.0040.00416.98
8.0.230.0030.00317.07
8.0.220.0070.00016.93
8.0.210.0080.00016.85
8.0.200.0000.00716.95
8.0.190.0050.00316.90
8.0.180.0040.00416.97
8.0.170.0000.00716.84
8.0.160.0050.00317.01
8.0.150.0030.00316.70
8.0.140.0040.00416.75
8.0.130.0030.00313.22
8.0.120.0000.00816.92
8.0.110.0040.00416.82
8.0.100.0040.00417.02
8.0.90.0040.00416.80
8.0.80.0030.01216.87
8.0.70.0050.00316.76
8.0.60.0040.00416.91
8.0.50.0000.00716.93
8.0.30.0110.00717.04
8.0.20.0060.01417.40
8.0.10.0030.00617.17
8.0.00.0110.00817.01
7.4.330.0000.00516.77
7.4.320.0030.00316.71
7.4.300.0070.00016.68
7.4.290.0030.00316.50
7.4.280.0070.00016.66
7.4.270.0000.00616.63
7.4.260.0000.00716.66
7.4.250.0040.00416.65
7.4.240.0030.00616.61
7.4.230.0040.00416.78
7.4.220.0090.00916.70
7.4.210.0070.00716.58
7.4.200.0030.00416.79
7.4.160.0120.00316.67
7.4.150.0180.00017.40
7.4.140.0090.00917.86
7.4.130.0080.00916.63
7.4.120.0120.00716.49
7.4.110.0080.00816.57
7.4.100.0070.01016.43
7.4.90.0110.00716.54
7.4.80.0140.00419.39
7.4.70.0060.01616.57
7.4.60.0100.00716.67
7.4.50.0070.00716.50
7.4.40.0180.00416.50
7.4.30.0120.00616.63
7.4.00.0110.00315.21
7.3.330.0030.00313.18
7.3.320.0030.00313.29
7.3.310.0030.00316.40
7.3.300.0000.00716.18
7.3.290.0100.00616.33
7.3.280.0090.01216.30
7.3.270.0070.01017.40
7.3.260.0040.01216.32
7.3.250.0120.00616.51
7.3.240.0090.01116.46
7.3.230.0140.00316.52
7.3.210.0070.01016.25
7.3.200.0030.01419.39
7.3.190.0100.01016.59
7.3.180.0130.01016.32
7.3.170.0160.00316.32
7.3.160.0080.01516.64
7.2.330.0090.00816.68
7.2.320.0090.00916.80
7.2.310.0100.00716.62
7.2.300.0030.01616.57
7.2.290.0030.01416.38
7.2.80.0180.00816.21
7.2.60.0070.00716.95
7.2.00.0070.00719.10
7.1.200.0080.00415.88
7.1.100.0060.00918.09
7.1.70.0060.00317.32
7.1.60.0040.01819.40
7.1.50.0180.01817.09
7.1.00.0070.07322.51
7.0.200.0000.01116.69
7.0.80.0370.06719.97
7.0.70.0570.05719.98
7.0.60.0500.04319.93
7.0.50.0270.05020.35
7.0.40.0030.06020.19
7.0.30.0030.04320.09
7.0.20.0070.04020.15
7.0.10.0070.04320.02
7.0.00.0000.05720.04
5.6.280.0000.03721.16
5.6.230.0070.08020.64
5.6.220.0170.07320.52
5.6.210.0070.03720.65
5.6.200.0030.05021.05
5.6.190.0000.06021.09
5.6.180.0070.04021.03
5.6.170.0030.05020.94
5.6.160.0030.04021.07
5.6.150.0070.03721.18
5.6.140.0000.04021.12
5.6.130.0030.04321.09
5.6.120.0070.08321.02
5.6.110.0070.05021.02
5.6.100.0100.08321.17
5.6.90.0000.05720.90
5.6.80.0100.03320.53
5.6.70.0100.04320.41
5.6.60.0070.03720.39
5.6.50.0100.04720.43
5.6.40.0130.03020.38
5.6.30.0030.04020.50
5.6.20.0030.04020.43
5.6.10.0030.04020.53
5.6.00.0030.04320.30
5.5.370.0100.05720.40
5.5.360.0070.08720.32
5.5.350.0100.07720.43
5.5.340.0170.06720.81
5.5.330.0100.04320.80
5.5.320.0030.04720.87
5.5.310.0000.04320.93
5.5.300.0000.04320.72
5.5.290.0070.08320.72
5.5.280.0030.08720.81
5.5.270.0030.04020.84
5.5.260.0030.05720.63
5.5.250.0030.04320.64
5.5.240.0030.04320.29
5.5.230.0070.04020.17
5.5.220.0070.04320.27
5.5.210.0100.03320.03
5.5.200.0100.04320.27
5.5.190.0070.03720.26
5.5.180.0070.03720.28
5.5.160.0070.03720.23
5.5.150.0030.04020.16
5.5.140.0000.04320.13
5.5.130.0070.03720.19
5.5.120.0070.03720.12
5.5.110.0070.03320.16
5.5.100.0030.03720.08
5.5.90.0130.03020.07
5.5.80.0000.04020.16
5.5.70.0070.05020.09
5.5.60.0070.03320.05
5.5.50.0030.03319.97
5.5.40.0070.04720.16
5.5.30.0000.07320.06
5.5.20.0030.03320.04
5.5.10.0030.04019.97
5.5.00.0030.05020.02

preferences:
40.58 ms | 401 KiB | 5 Q