1

我想写一个像这个函数(str,find){}这样的函数,这样当我有一个像这样的str

大家好,大家好,大家好,大家好

并找到像“你好”这样的词,我得到了结果

<span class="match">Hello</span> every body, <span class="match">HeLlo</span> and <span class="match">hElLo</span> everyone blah
4

1 回答 1

5
echo preg_replace('~Hello~i', '<span blabla>\0</span>', 'Hello every body, HeLlo and hElLo everyone blah');

<span blabla>Hello</span> every body, <span blabla>HeLlo</span> and <span blabla>hElLo</span> everyone blah
于 2012-07-10T07:28:46.113 回答