第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何更改PHP文件中文本的輸出顏色

如何更改PHP文件中文本的輸出顏色

PHP
三國(guó)紛爭(zhēng) 2021-05-03 14:35:36
Test.txt文件包含一些文本。如何從PHP文件中更改文本的輸出顏色。Test.txt fileThe output should be like this:This is a | text (The word "text" should be red)This is another | text (The word "text" should be red)This is the | best (The word "best" should be red)
查看完整描述

2 回答

?
慕田峪9158850

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊

你可以做到


$text = file_get_contents('file.txt');

$text = str_replace('text',"<span style='color:red;'>text</span>" , $text);

echo $text;

對(duì)于多項(xiàng)選擇,請(qǐng)嘗試此


$text = file_get_contents('files.txt');

$pattern = ['text','best'];

$replacements = ["<span style='color:red;'>text</span>","<span style='color:red;'>best</span>"];

$text = str_replace($pattern,$replacements , $text);

echo $text;

要更改|使用此后出現(xiàn)的字符串的顏色


$fn = fopen("files.txt","r");

while(! feof($fn))  {

    $line = fgets($fn);

    $needle = substr($line, strpos($line, '|')+1, strlen($line));

    echo $line   = str_replace($needle, "<span style='color:red;'>{$needle}</span>", $line);

   echo '<hr>';

}

fclose($fn);


查看完整回答
反對(duì) 回復(fù) 2021-05-21
?
嗶嗶one

TA貢獻(xiàn)1854條經(jīng)驗(yàn) 獲得超8個(gè)贊

您無(wú)法使用PHP更改文本顏色。您必須使用HTML文檔上的CSS更改文本顏色。


查看完整回答
反對(duì) 回復(fù) 2021-05-21
  • 2 回答
  • 0 關(guān)注
  • 340 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)