Convert Arabic characters to Farsi (Persian) and Farsi characters to Arabic using this web-based converter. Easily translate text between the two languages.
<?php
function arabic_to_farsi( $string = '' ) {
$arabic_characters = array( 'ة', 'ك', 'دِ', 'بِ', 'زِ', 'ذِ', 'شِ', 'سِ', 'ى', 'ي', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', '٠' );
$farsi_characters = array( 'ه', 'ک', 'د', 'ب', 'ز', 'ذ', 'ش', 'س', 'ی', 'ی', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰' );
return str_replace( $arabic_characters, $farsi_characters, $string );
}
function farsi_to_arabic( $string = '' ) {
$farsi_characters = array( 'ه', 'ک', 'د', 'ب', 'ز', 'ذ', 'ش', 'س', 'ی', 'ی', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰' );
$arabic_characters = array( 'ة', 'ك', 'دِ', 'بِ', 'زِ', 'ذِ', 'شِ', 'سِ', 'ى', 'ي', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', '٠' );
return str_replace( $farsi_characters, $arabic_characters, $string );
}
?>
Copy to Clipboard