如何将带有 php 的 css 类添加到已经包含该元素的字符串中


How add a css class with php to a string already containing the element?

我有一个包含字符串$activities->action的对象项,如下所示:

["action"]=> string() "<a href="link">user070</a> posted an update <a href="linkitem">here</a>

html 元素已经定义,所以我不能/不知道如何在这里添加一个 CSS 类。

我将如何在第一个链接上添加带有PHP的CSS类?

如果需要,如何将 css 类添加到第二个链接?

任何帮助将不胜感激!

["action"]=> string() "<a href="link">user070</a> posted an update <a href="linkitem" class="someClass">here</a>

还是您需要的更多?