Last active
November 14, 2019 08:38
-
-
Save miftahafina/b1b5c071270579ed602360907ccc8093 to your computer and use it in GitHub Desktop.
#Helper - Convert from western to eastern arabic numeral
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 | |
namespace app\Helpers; | |
class EasternArabic | |
{ | |
public static function convert($number, $process = false) | |
{ | |
if ($process) { | |
$western = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']; | |
$eastern = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', ',']; | |
return str_replace($western, $eastern, $number); | |
} | |
return $number; | |
} | |
} | |
// Thanks to @kadimi, https://gist.github.com/kadimi/9912940 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment