我写了下面的代码,但它运行不正常:
$t = "۰۱۲۳۴۵۶۷۸۹٤٥٦";
$correct = array("0","1","2","3","4","5","6","7","8","9","4","5","6");
$wrong = array("٠","١","٢","٣","٤","٥","٦","٧","٨","٩","۴","۵","۶");
echo $t = str_replace($wrong,$correct, $t);
结果不对
۰۱۲۳456۷۸۹۰۱۲۳456۷۸۹456
我在堆栈中搜索相同的问题,但答案对我没有帮助。
最佳答案
Use this code:-
$t = "۰۱۲۳٤٥٦";
$text = preg_replace(
array("٠","١","٢","٣","٤","٥","٦",),
array("0","1","2","3","4","5","6",),
$t );
关于php - str_replace 不适用于某些字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13467817/