PHP函数类似于这个JavaScript函数

Jud*_*ude 3 javascript php function preg-replace

这个JavaScript函数我在PHP中需要一个类似的函数

text = text.replace(/ffc/g, "Hello");
Run Code Online (Sandbox Code Playgroud)

我认为preg_replace会做,但我不知道如何编写表达式..

我希望正则表达式与/ffc/g上面的类似,我需要的是在执行替换时匹配完整的单词和大小写...

Eri*_*rik 5

$text = preg_replace('/ffc/', 'replacement text',  $subject);
Run Code Online (Sandbox Code Playgroud)

PHP的在线手册非常棒,是其中一种语言的最佳功能:

http://php.net/preg_replace