I'm trying to write function to do the number_format()
job for the non-ascii numbers , specifically perso-arabic numbers.
First i have to exchange the numbers which leaves me with a string of non-ascii characters:
$n = 133;
$n = exchange($n);
echo $n ;
//result : ١٣٣
The problem is when I add the commas to the number or rather string, my final result comes with some � characters.
Here is the function that I use to add the commas:
static public function addcomma($number)
{
$i = strlen($number)-1;
$c = 0 ;
for($i ; $i >= 0 ; $i--){
$c++;
if($c == 1 )
$y =mb_substr($number, $i, 1);
else
$y .= mb_substr($number, $i, 1);
if($c%3 == 0 && $i != 0 )
$y .=',';
}
$y = strrev($y);
return $y;
}
And this is the result for $n = ١٣٣
:
٣,٣�,�١