我想使用 CSS 和条件更改在 ECHO 函数中找到的文本的颜色。
例如:
我使用 ECHO 函数调用文本:
echo ": The net value of the entire order"
echo ": The gross value of the entire order"
echo ": The gross value of the entire order"
echo ": The net value of the entire order"
然后使用条件“if”找到单词“net”或“gross”并将颜色更改为红色或蓝色..
怎么做?我正在寻找论坛,但帖子仅针对变量中的赋值,我想从 ECHO 函数更改颜色,这似乎毫无意义,但如果有成千上万这样的话?
我向你求助, 我是这门语言的新手。
最佳答案
$str = ": The net value of the entire order"
$str = str_replace('net', '<span style="color:red">net</span>', $str);
$str = str_replace('gross', '<span style="color:blue">gross</span>', $str);
echo $str;
关于php - 查找单词并更改颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52401887/