Skip to content

Instantly share code, notes, and snippets.

@amirasaran
Last active May 26, 2024 01:35
Show Gist options
  • Save amirasaran/f268960dd0b146995c9fdffb3e0ce14c to your computer and use it in GitHub Desktop.
Save amirasaran/f268960dd0b146995c9fdffb3e0ce14c 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);
}
?>
@RezaAghaeiii
Copy link

قصد داشتم برای تبدیل عربی به فارسی از پکیج استفاده کنم ولی وقتی با یه فاکشن اوکی میشه فوق العاده است

@akoSalman
Copy link

Awesome, TNX

@sadrahoseini
Copy link

دستت درد نکنه :)

@hsa599
Copy link

hsa599 commented Jan 30, 2021

زحمت کشیدین
کاراکتر ة رو هم اضافه کنید.

@PedramFadaei
Copy link

PedramFadaei commented Dec 13, 2022

ممنونم بابت اشتراک گذاری

@AhmadVakil
Copy link

Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment