3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 //*/ ?>
based on 57650

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).
Note: hhvm uses a JIT which only kicks in after a few runs. Since we run scripts only once, hhvm always runs slower.

VersionSystem time (s)User time (s)Memory (MiB)
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