とりあえず混合の場合先にかいてあったほうで
php
1/* ファイルポインタをオープン */
2$file = fopen("list.txt", "r");
3
4/* ファイルを1行ずつ出力 */
5if($file){
6 while ($line = fgets($file)) {
7 $matches = array();
8 if(preg_match("/red|blue|green/",$line,$matches))
9 {
10 printf("<span style='color:%s'>%s</span><br>",$matches[0],$line);
11 }
12 else
13 echo $line.'<br>';
14 }
15}
追記
strposで作成したいという部分を読み飛ばしてました、すいません
preg_matchで正規表現で検索しているところをstrposでred,blue,green3回検索しORで判定に変更すればそうなります