【发布时间】:2015-11-06 12:24:45
【问题描述】:
我想用 preg_replace 替换外部文件中的一些字符。
我正在尝试下面的代码:
$arch = 'myfile.txt';
$filecontent = file_get_contents($arch);
$patrones = array();
$patrones[0] = '/á/';
$patrones[1] = '/à/';
$patrones[2] = '/ä/';
$patrones[3] = '/â/';
$sustituciones = array();
$sustituciones[0] = 'a';
$sustituciones[1] = 'a';
$sustituciones[2] = 'a';
$sustituciones[3] = 'a';
preg_replace($patrones, $sustituciones, $filecontent);
但它不起作用。我怎么能这样做?
有没有更好的方法?
非常感谢。
【问题讨论】:
-
这个stackoverflow.com/a/3542866/594138 对你有用吗?
标签: php preg-replace