1

I have the following PHP code which aims to replace any arabic number with english one

$arabic = ['٠','١','٢','٣','٤','٥','٦','٧','٨','٩'];
$english = ['0','1','2','3','4','5','6','7','8','9'];
$id =  str_replace($arabic, $english, '۲٤۲۰۸۹۳۰٥٥');
echo $id; // ۲4۲۰۸۹۳۰55

the above code should replace all numbers but obviously it replaced the second number and the last two only, so what seems to be the issue here?

thanks guys.

  • i pasted `۲` input against `٧` arabic, its not the same, therefor will not match – Kevin May 06 '20 at 08:24
  • it seems like mixed persian arabic, anyways you can use this https://stackoverflow.com/a/39066589/3859027 – Kevin May 06 '20 at 08:29

0 Answers0