Source: arabic_utf8.phps - download
<?php
/* 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * arabic_utf8.phps 0.1
 * by daif alotaibi (http://daif.net)
 * daif@daif.net
 * 
 * Link:
 *  http://daif.net/script/arabic_utf8.phps
 *
 * Examples:
 *  $str = '‫ﺍﻟﻄﺒﺎﻋﺔ‬ ‫ﻭﻗﺖ';
 *  $str = Arabic_utf8($str, TRUE);
 *  print $str;
 * 
*/

    
$str '‫ﺍﻟﻄﺒﺎﻋﺔ‬ ‫ﻭﻗﺖ';
    
$str Arabic_utf8($strTRUE);
    print 
$str;


function 
Arabic_utf8($str$reverse=FALSE) {
    if(
$reverse) {
        
$str  implode(' 'array_reverse(explode(' '$str)));
    }
    
$utf8 = [
        
''   => [chr(226).chr(128).chr(171),chr(226).chr(128).chr(172)],
        
'ا'  => ['ﺁ','ﺂ','ﺃ','ﺄ','ﺇ','ﺈ','ﺍ','ﺎ'],
        
'ب'  => ['ﺏ','ﺐ','ﺑ','ﺒ'],
        
'ت'  => ['ﺕ','ﺖ','ﺗ','ﺘ'],
        
'ث'  => ['ﺙ','ﺚ','ﺛ','ﺜ'],
        
'ج'  => ['ﺝ','ﺞ','ﺟ','ﺠ'],
        
'ح'  => ['ﺡ','ﺢ','ﺣ','ﺤ'],
        
'خ'  => ['ﺥ','ﺦ','ﺧ','ﺨ'],
        
'د'  => ['ﺩ','ﺪ'],
        
'ذ'  => ['ﺫ','ﺬ'],
        
'ر'  => ['ﺭ','ﺮ'],
        
'ز'  => ['ﺯ','ﺰ'],
        
'س'  => ['ﺱ','ﺲ','ﺳ','ﺴ'],
        
'ش'  => ['ﺵ','ﺶ','ﺷ','ﺸ'],
        
'ص'  => ['ﺹ','ﺺ','ﺻ','ﺼ'],
        
'ض'  => ['ﺽ','ﺾ','ﺿ','ﻀ'],
        
'ط'  => ['ﻁ','ﻂ','ﻃ','ﻄ'],
        
'ظ'  => ['ﻅ','ﻆ','ﻇ','ﻈ'],
        
'ع'  => ['ﻉ','ﻊ','ﻋ','ﻌ'],
        
'غ'  => ['ﻍ','ﻎ','ﻏ','ﻐ'],
        
'ف'  => ['ﻑ','ﻒ','ﻓ','ﻔ'],
        
'ق'  => ['ﻕ','ﻖ','ﻗ','ﻘ'],
        
'ك'  => ['ﻙ','ﻚ','ﻛ','ﻜ'],
        
'ل'  => ['ﻝ','ﻞ','ﻟ','ﻠ'],
        
'م'  => ['ﻡ','ﻢ','ﻣ','ﻤ'],
        
'ن'  => ['ﻥ','ﻦ','ﻧ','ﻨ'],
        
'ه'  => ['ﻩ','ﻪ','ﻫ','ﻬ'],
        
'ة'  => ['ﺓ','ﺔ'],
        
'و'  => ['ﻭ','ﻮ'],
        
'ؤ'  => ['ﺅ','ﺆ'],
        
'ئ'  => ['ﺋ','ﺌ','ﺊ','ﺉ'],
        
'ي'  => ['ﻱ','ﻲ','ﻳ','ﻴ'],
        
'ى'  => ['ﻯ','ﻰ'],
        
'لا' => ['ﻵ','ﻶ','ﻷ','ﻸ','ﻹ','ﻺ','ﻻ','ﻼ'],
    ];
    foreach (
$utf8 as $chr => $chrs) {
        
$str str_replace($chrs$chr$str);
    }
    return 
$str;
}
?>