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