0
我试图将^
更换为<span>
。但是,我失败了。我尝试了str_replace
,但无法正常工作。更改字符串值
所以,我原来的值是:
^ffcb4a Special reward of the territory war. \rUsed to manufacture Rank IX gears. \rDon't lose this.
你可以看到,有一个颜色值,开始与^
,我想替换为:'<span style=color"#ffcb4a">
。
但我str_replace
,我得到这个:
<span style='color:#'ffcb4a Special reward of the territory war. \rUsed to manufacture Rank IX gears. \rDon't lose this.
就像你看到的,这是行不通的。
$item_description = str_replace('^', "<span style='color:#'" . '', $item_description);
谢谢!我非常感激。而且,如果我的文本与颜色“合并”?例如:^ ffcb4aSpecial – Peter
您可以在'^'后拉前6个字符。它会始终是6个字符.. – chris85
更新为这种情况。 – chris85