Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save amirhp-com/bb9d3b74d5b4d18fbfed5eb79e2f73e5 to your computer and use it in GitHub Desktop.
Save amirhp-com/bb9d3b74d5b4d18fbfed5eb79e2f73e5 to your computer and use it in GitHub Desktop.
convert Arabic character to Persian (Farsi) - PHP
<?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