Created
February 4, 2018 08:29
-
-
Save dhassanali/1796599e6d0e455bd0adc44c1d70f73b to your computer and use it in GitHub Desktop.
Convert to arabic digits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: dhassanali | |
* Date: 12/4/17 | |
* Time: 8:56 PM | |
*/ | |
class Digit | |
{ | |
public static function toArabic($str) | |
{ | |
return str_replace( | |
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], | |
['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'], | |
$str | |
); | |
} | |
public static function toEnglish($str) | |
{ | |
return str_replace( | |
['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'], | |
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], | |
$str | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment