Last active
January 11, 2023 21:57
-
-
Save m-ostadi/55388d367c0a8425d92f2453dd8b0d74 to your computer and use it in GitHub Desktop.
convert persian and arabic numbers to english in php
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 | |
function number2latin($str) | |
{ | |
$en_digits = ['0','0','1','1','2','2','3','3','4','4','5','5','6','6','7','7','8','8','9','9']; | |
$fa_ar_digits = ['٠','۰','۱','١','٢','۲','٣','۳','٤','۴','٥','۵','٦','۶','٧','۷','٨','۸','٩','۹']; | |
$str = str_replace($fa_ar_digits, $en_digits, $str); | |
return $str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment