Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 PHP 函数并且遇到了这个问题:
我需要更改函数 *ereg_replace*
$row[$j] = ereg_replace("\n", "\\n", $row[$j]);
到 *preg_replace*
怎么做 ?
谢谢
好吧,这不是您正在使用的正则表达式。你在这里想要的是str_replace.
str_replace
$row[$j] = str_replace("\n", "\\n", $row[$j]);
而是阅读什么是正则表达式以及它们是如何工作的。