Forked from amirasaran/Arabic character to Persian (Farsi) - PHP
Created
September 19, 2021 17:20
-
-
Save mohsenmojadam2019/c8d3358ac89464c50b28a2cba3e3976e to your computer and use it in GitHub Desktop.
convert Arabic character to Persian (Farsi) - 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 | |
public static function arabicToPersian($string) | |
{ | |
$characters = [ | |
'ك' => 'ک', | |
'دِ' => 'د', | |
'بِ' => 'ب', | |
'زِ' => 'ز', | |
'ذِ' => 'ذ', | |
'شِ' => 'ش', | |
'سِ' => 'س', | |
'ى' => 'ی', | |
'ي' => 'ی', | |
'١' => '۱', | |
'٢' => '۲', | |
'٣' => '۳', | |
'٤' => '۴', | |
'٥' => '۵', | |
'٦' => '۶', | |
'٧' => '۷', | |
'٨' => '۸', | |
'٩' => '۹', | |
'٠' => '۰', | |
]; | |
return str_replace(array_keys($characters), array_values($characters),$string); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment