0

这是从 html dom 获取的文本:

"Established in <b>2004</b>, <strong>AssistanZ</strong> has become one of the most"

我需要将上面的字符串替换为"Established in 2004, AssistanZ has become one of the most".

由于 html 元素,字符串比较不起作用。我无法替换 html,因为它会动态出现。

你能告诉任何人如何解决这个问题。提前致谢。

$oldValue = $value->skey;
$newValue = $value->svalue;
str_replace($oldValue,$newValue,$text);
4

2 回答 2

2

如果你想摆脱 html 标签,使用 strip_tags 功能

strip_tags("Established in <b>2004</b>, <strong>AssistanZ</strong> has become one of the most")
于 2019-10-11T08:42:50.303 回答
0

下面是实际代码:

$text = "Established in 2004, AssistanZ has become one of the most amazing things on the planet.";
$oldvalue = strip_tags("Established in <b>2004</b>, <strong>AssistanZ</strong> has become one of the most");
$newValue = "I am one of the";

echo str_replace($oldvalue, $newValue, $text);
于 2019-10-11T08:50:36.800 回答