Skip to content

Instantly share code, notes, and snippets.

@miftahafina
Last active November 14, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miftahafina/b1b5c071270579ed602360907ccc8093 to your computer and use it in GitHub Desktop.
Save miftahafina/b1b5c071270579ed602360907ccc8093 to your computer and use it in GitHub Desktop.
#Helper - Convert from western to eastern arabic numeral
<?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