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("r")); 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.0110.00716.49
8.3.50.0100.00821.11
8.3.40.0140.00318.79
8.3.30.0090.00918.64
8.3.20.0040.00420.35
8.3.10.0070.00021.85
8.3.00.0070.00021.73
8.2.180.0150.00416.50
8.2.170.0070.00722.96
8.2.160.0030.01020.51
8.2.150.0050.00324.18
8.2.140.0050.00224.66
8.2.130.0040.00421.14
8.2.120.0080.00026.35
8.2.110.0090.00021.00
8.2.100.0080.00417.93
8.2.90.0060.00319.36
8.2.80.0040.00417.97
8.2.70.0060.00317.38
8.2.60.0040.00418.05
8.2.50.0080.00018.09
8.2.40.0040.00422.32
8.2.30.0000.00819.49
8.2.20.0040.00419.47
8.2.10.0020.00518.05
8.2.00.0050.00318.23
8.1.280.0120.00625.92
8.1.270.0070.00022.05
8.1.260.0040.00428.09
8.1.250.0070.00028.09
8.1.240.0100.00022.55
8.1.230.0030.00919.16
8.1.220.0030.00517.74
8.1.210.0030.00718.77
8.1.200.0060.00317.36
8.1.190.0080.00017.36
8.1.180.0050.00318.10
8.1.170.0080.00018.48
8.1.160.0050.00220.73
8.1.150.0000.00718.93
8.1.140.0050.00319.52
8.1.130.0050.00217.57
8.1.120.0000.00717.50
8.1.110.0000.00717.54
8.1.100.0050.00217.53
8.1.90.0040.00417.57
8.1.80.0040.00417.64
8.1.70.0040.00417.43
8.1.60.0000.01117.66
8.1.50.0040.00417.55
8.1.40.0040.00417.60
8.1.30.0050.00317.77
8.1.20.0040.00417.77
8.1.10.0040.00417.53
8.1.00.0000.00717.49
8.0.300.0050.00218.77
8.0.290.0040.00416.75
8.0.280.0040.00418.56
8.0.270.0070.00017.24
8.0.260.0080.00016.91
8.0.250.0000.00817.00
8.0.240.0040.00417.16
8.0.230.0000.00717.07
8.0.220.0070.00016.95
8.0.210.0030.00517.01
8.0.200.0070.00017.02
8.0.190.0040.00417.01
8.0.180.0050.00216.96
8.0.170.0050.00316.96
8.0.160.0000.00816.96
8.0.150.0000.00716.97
8.0.140.0040.00416.90
8.0.130.0030.00313.33
8.0.120.0050.00316.97
8.0.110.0040.00416.86
8.0.100.0040.00416.85
8.0.90.0060.00316.96
8.0.80.0040.01116.96
8.0.70.0080.00017.00
8.0.60.0080.00016.82
8.0.50.0050.00216.96
8.0.30.0110.00917.43
8.0.20.0120.00617.44
8.0.10.0050.00417.16
8.0.00.0100.00716.86
7.4.330.0000.00516.71
7.4.320.0030.00316.59
7.4.300.0040.00416.57
7.4.290.0030.00316.68
7.4.280.0040.00416.59
7.4.270.0030.00316.51
7.4.260.0060.00016.49
7.4.250.0040.00416.50
7.4.240.0040.00416.70
7.4.230.0070.00016.58
7.4.220.0140.01016.61
7.4.210.0070.01316.70
7.4.200.0030.00316.57
7.4.160.0000.01516.74
7.4.150.0100.00717.40
7.4.140.0120.00917.86
7.4.130.0120.00516.60
7.4.120.0070.01116.68
7.4.110.0160.00316.61
7.4.100.0040.01416.54
7.4.90.0120.00616.73
7.4.80.0110.00719.39
7.4.70.0100.00616.59
7.4.60.0120.00616.63
7.4.50.0060.01216.63
7.4.40.0080.01416.56
7.4.30.0070.01016.66
7.4.00.0100.00814.96
7.3.330.0060.00013.17
7.3.320.0070.00013.13
7.3.310.0040.00416.34
7.3.300.0030.00316.19
7.3.290.0080.00816.29
7.3.280.0110.00816.28
7.3.270.0060.01217.40
7.3.260.0120.00616.59
7.3.250.0080.01016.44
7.3.240.0080.01016.49
7.3.230.0110.00516.49
7.3.210.0070.01016.39
7.3.200.0100.00719.39
7.3.190.0070.01516.62
7.3.180.0070.01416.41
7.3.170.0190.00016.45
7.3.160.0060.01316.49
7.3.120.0040.01114.93
7.3.110.0060.01014.71
7.3.100.0060.00914.97
7.3.90.0080.00815.09
7.3.80.0060.00914.94
7.3.70.0120.00314.84
7.3.60.0000.00915.00
7.3.50.0000.01314.76
7.3.40.0090.00314.77
7.3.30.0100.00014.83
7.3.20.0060.00316.90
7.3.10.0060.00616.45
7.3.00.0040.01116.56
7.2.330.0130.00316.57
7.2.320.0100.00716.57
7.2.310.0190.00416.51
7.2.300.0120.00916.72
7.2.290.0070.00916.58
7.2.250.0040.01115.05
7.2.240.0070.01415.34
7.2.230.0090.00914.66
7.2.220.0100.00615.00
7.2.210.0030.00915.22
7.2.200.0000.01915.05
7.2.190.0050.00514.92
7.2.180.0110.00614.77
7.2.170.0030.00615.02
7.2.130.0070.00716.93
7.2.120.0040.01116.93
7.2.110.0040.00416.92
7.2.100.0070.00316.96
7.2.90.0130.00017.05
7.2.80.0090.00616.80
7.2.70.0060.01017.11
7.2.60.0060.01016.81
7.2.50.0090.00616.96
7.2.40.0110.00416.97
7.2.30.0090.00617.04
7.2.20.0030.01017.04
7.2.10.0030.00916.92
7.2.00.0020.01418.26
7.1.330.0000.01115.85
7.1.320.0030.00715.68
7.1.310.0100.00315.61
7.1.300.0030.01215.89
7.1.290.0040.01116.05
7.1.280.0030.00715.91
7.1.270.0070.00415.85
7.1.260.0000.01415.88
7.1.250.0030.01016.05
7.1.240.0060.00615.66
7.1.230.0000.01216.05
7.1.220.0080.00415.88
7.1.210.0000.01015.97
7.1.200.0050.00615.90
7.1.190.0040.00415.61
7.1.180.0030.00715.80
7.1.170.0060.00315.99
7.1.160.0040.01116.04
7.1.150.0030.01016.07
7.1.140.0070.01015.66
7.1.130.0060.00615.85
7.1.120.0000.00915.56
7.1.110.0080.00816.04
7.1.100.0070.01016.85
7.1.90.0040.00415.77
7.1.80.0130.00015.86
7.1.70.0020.01116.44
7.1.60.0060.01017.60
7.1.50.0000.01216.52
7.1.40.0080.00015.68
7.1.30.0060.00615.58
7.1.20.0070.00315.86
7.1.10.0030.00515.78
7.1.00.0020.04319.11
7.0.330.0000.01315.23
7.0.320.0060.00315.23
7.0.310.0090.00415.49
7.0.300.0040.00815.44
7.0.290.0100.00315.06
7.0.280.0040.00815.36
7.0.270.0070.00715.03
7.0.260.0040.01115.36
7.0.250.0060.00915.46
7.0.240.0030.01215.46
7.0.230.0000.01115.25
7.0.220.0050.00215.18
7.0.210.0030.00615.39
7.0.200.0020.00716.04
7.0.190.0040.00715.27
7.0.180.0050.00215.45
7.0.170.0090.00615.45
7.0.160.0030.00915.03
7.0.150.0090.00315.40
7.0.140.0030.00615.11
7.0.130.0060.00815.22
7.0.120.0030.00615.26
7.0.110.0080.00815.20
7.0.100.0060.00915.39
7.0.90.0060.00915.27
7.0.80.0030.04717.67
7.0.70.0060.03217.56
7.0.60.0280.04517.54
7.0.50.0100.02317.68
7.0.40.0040.03016.73
7.0.30.0020.02916.79
7.0.20.0030.02816.71
7.0.10.0070.02216.68
7.0.00.0050.02516.78
5.6.380.0070.00314.08
5.6.370.0070.00013.98
5.6.360.0110.00414.30
5.6.350.0090.00914.73
5.6.340.0080.00414.30
5.6.330.0060.00614.64
5.6.320.0040.01114.48
5.6.310.0030.00513.87
5.6.300.0030.01214.38
5.6.290.0080.00814.12
5.6.280.0110.02717.89
5.6.270.0090.00914.25
5.6.260.0070.00714.23
5.6.250.0030.00314.38
5.6.240.0070.00714.22
5.6.230.0060.02617.49
5.6.220.0070.04217.38
5.6.210.0070.02717.54
5.6.200.0040.05317.84
5.6.190.0030.03217.77
5.6.180.0100.02117.74
5.6.170.0050.02517.70
5.6.160.0040.02417.61
5.6.150.0050.02317.59
5.6.140.0050.03717.78
5.6.130.0040.02417.66
5.6.120.0040.02717.66
5.6.110.0050.02617.54
5.6.100.0050.02717.70
5.6.90.0030.02717.54
5.6.80.0070.02317.21
5.6.70.0080.01817.32
5.6.60.0000.02417.16
5.6.50.0090.01617.34
5.6.40.0050.02317.26
5.6.30.0020.02717.23
5.6.20.0040.02117.34
5.6.10.0050.02717.31
5.6.00.0030.02417.16
5.5.380.0110.00011.18
5.5.370.0030.04515.80
5.5.360.0060.04615.87
5.5.350.0000.04215.79
5.5.340.0060.02715.91
5.5.330.0080.04316.05
5.5.320.0020.02716.05
5.5.310.0050.02816.09
5.5.300.0080.01616.03
5.5.290.0070.01816.09
5.5.280.0050.02316.00
5.5.270.0040.02315.97
5.5.260.0100.01616.06
5.5.250.0100.01815.84
5.5.240.0090.01915.78
5.5.230.0050.01915.71
5.5.220.0070.02015.73
5.5.210.0070.01815.74
5.5.200.0060.02415.73
5.5.190.0080.02015.71
5.5.180.0050.02615.64
5.5.170.0000.00711.22
5.5.160.0050.02215.61
5.5.150.0030.02215.75
5.5.140.0000.02715.64
5.5.130.0030.02515.71
5.5.120.0050.02115.63
5.5.110.0070.02015.69
5.5.100.0030.02315.62
5.5.90.0060.01815.60
5.5.80.0050.02015.73
5.5.70.0050.02215.67
5.5.60.0050.02215.66
5.5.50.0000.02715.63
5.5.40.0030.02315.71
5.5.30.0000.02615.62
5.5.20.0050.02315.65
5.5.10.0060.02615.68
5.5.00.0070.02015.64

preferences:
49.48 ms | 401 KiB | 5 Q