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 //*/ ?>
Output for git.master, git.master_jit, rfc.property-hooks
٠٧:٥٣

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.81 ms | 401 KiB | 8 Q