0

配列で文字列置換を実行しようとしています。

私は持っている..

str_replace('texts', 'testssssss', $test->html);

$test->htmlリターン_

すべてのテキストをtestssssssに置き換えたい..

key 1

<div>
   <a href='texts.company.name.html'>test</a>
</div>



Key 2

<div>
    other html...
</div>


Key 3

<div>
    other html...
</div>

Key 4

<div>
   <a href='texts.department.name.html'>department</a>
</div>

more...

助けてくれてありがとう!

4

2 に答える 2

5

新しい値をどこかに割り当てる必要があります。str_replace は件名を自動的に上書きしません。

$test->html = str_replace('texts', 'testssssss', $test->html);
于 2012-10-18T16:54:34.833 に答える
0

関数は文字列を返すので、それを開始する必要があります $variable =str_replace

于 2012-10-18T16:56:15.027 に答える