Skip to content

Instantly share code, notes, and snippets.

@m-ostadi
Last active January 11, 2023 21:57
Show Gist options
  • Save m-ostadi/55388d367c0a8425d92f2453dd8b0d74 to your computer and use it in GitHub Desktop.
Save m-ostadi/55388d367c0a8425d92f2453dd8b0d74 to your computer and use it in GitHub Desktop.
convert persian and arabic numbers to english in php
<?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