I am working with below code in php to show the arabic letters in roman ABCD
characters as defined below in my code.
But it is not displaying properly. It is losing the character sorting also and not displaying some of the characters according to my string.
it is showing as _space_aabtkhlmn
and it should show as khatm_space_alanbyaa
.
I can not figure it out where i am wrong.
Please help why it is showing wrong?
<!DOCTYPE HTML>
<head>
<?php header('Content-type: text/html; charset=utf-8'); ?>
</head>
<body>
<?php
echo $mystr = "خاتم الانبیاء";
echo "<hr>";
$empty = " ";
$a = "ء";
$a1 = "ا";
$a2 = "آ";
$b = "ب";
$c = "پ";
$d = "ة";
$e = "ت";
$ea = "ٹ";
$f = "ث";
$g = "ج";
$h = "چ";
$ha = "ح";
$i = "خ";
$j = "د";
$ja = "ڈ";
$k = "ذ";
$l = "ر";
$m = "ڑ";
$ma = "ز";
$mb = "ژ";
$n = "س";
$na = "ش";
$nb = "ص ";
$nc = "ض";
$o = "ط";
$p = "ظ";
$q = "ع";
$r = "غ";
$s = "ف";
$t = "ق";
$ta = "ک";
$tb = "گ";
$u = "ل";
$v = "م";
$w = "ن";
$wa = "ں";
$x = "ہ";
$xa = "ھ";
$y = "و";
$ya = "ے";
$yb = "ى";
$yc = "ي";
$me = preg_split('//u', $mystr);
$imp = implode(",", $me);
echo "<div style='direction: ltr;'>";
if(stripos($imp, $empty) == true){ echo "_space_"; }
if(stripos($imp, $a) == true){ echo "a"; }
if(stripos($imp, $a1) == true){ echo "a";}
if(stripos($imp, $a2) == true){ echo "aa";}
if(stripos($imp, $b) == true){ echo "b";}
if(stripos($imp, $c) == true){ echo "p";}
if(stripos($imp, $d) == true){ echo "h";}
if(stripos($imp, $e) == true){ echo "t";}
if(stripos($imp, $ea) == true){ echo "t";}
if(stripos($imp, $f) == true){ echo "s";}
if(stripos($imp, $g) == true){ echo "j";}
if(stripos($imp, $h) == true){ echo "ch";}
if(stripos($imp, $ha) == true){ echo "h";}
if(stripos($imp, $i) == true){ echo "kh";}
if(stripos($imp, $j) == true){ echo "d";}
if(stripos($imp, $ja) == true){ echo "d";}
if(stripos($imp, $k) == true){ echo "z";}
if(stripos($imp, $l) == true){ echo "r";}
if(stripos($imp, $m) == true){ echo "rr";}
if(stripos($imp, $ma) == true){ echo "z";}
if(stripos($imp, $mb) == true){ echo "x";}
if(stripos($imp, $n) == true){ echo "s";}
if(stripos($imp, $na) == true){ echo "sh";}
if(stripos($imp, $nb) == true){ echo "s";}
if(stripos($imp, $nc) == true){ echo "d";}
if(stripos($imp, $o) == true){ echo "t";}
if(stripos($imp, $p) == true){ echo "z";}
if(stripos($imp, $q) == true){ echo "u";}
if(stripos($imp, $r) == true){ echo "gh";}
if(stripos($imp, $s) == true){ echo "f";}
if(stripos($imp, $t) == true){ echo "q";}
if(stripos($imp, $ta) == true){ echo "k";}
if(stripos($imp, $tb) == true){ echo "g";}
if(stripos($imp, $u) == true){ echo "l";}
if(stripos($imp, $v) == true){ echo "m";}
if(stripos($imp, $w) == true){ echo "n";}
if(stripos($imp, $wa) == true){ echo "n";}
if(stripos($imp, $x) == true){ echo "h";}
if(stripos($imp, $xa) == true){ echo "h";}
if(stripos($imp, $y) == true){ echo "o";}
if(stripos($imp, $ya) == true){ echo "y";}
if(stripos($imp, $yb) == true){ echo "y";}
if(stripos($imp, $yc) == true){ echo "y";}
echo "</div>";
echo "<hr>";
?>
</body>
</html>