Schlo_50 Posted February 12, 2008 Share Posted February 12, 2008 Hey guys, I have some values pulled from a .txt file which are echo'ed out on a page. E.g Value1, Value2, Value3, Value4 What i'd like to do is get some code to highlight each output in this order: red, yellow and blue. E.g Red | Yellow | Blue | Red Value1 | Value2 | Value3 | Value4 I have so far attempted this but need some help/ideas about what to try next? I have defined three variables for the red, yellow and blue html tags. But need to apply them in order still. $lines = file("file.txt"); //open file foreach ($lines as $line) { $data[$key] = explode("|", $line); $catname = trim($data[$key][1]); //define data needed $a = "<font style=\"background-color: red\" size=\"3\">"; //red html highlight $b = "<font style=\"background-color: yellow\" size=\"3\">"; //yellow html highlight $c = "<font style=\"background-color: blue\" size=\"3\">"; //blue html highlight $array = array($a, $b, $c); //i think i need to use a array? print '<strong>'.$catname.'</strong></font>'; // print values and html highlight Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/90658-colour-ordered-text/ Share on other sites More sharing options...
sasa Posted February 12, 2008 Share Posted February 12, 2008 try $col=0; $lines = file("file.txt"); //open file $a = "<font style=\"background-color: red\" size=\"3\">"; //red html highlight $b = "<font style=\"background-color: yellow\" size=\"3\">"; //yellow html highlight $c = "<font style=\"background-color: blue\" size=\"3\">"; //blue html highlight $array = array($a, $b, $c); //i think i need to use a array? foreach ($lines as $line) { $data[$key] = explode("|", $line); $catname = trim($data[$key][1]); //define data needed print $array[$col++ % 3].'<strong>'.$catname.'</strong></font>'; // print values and html highlight Link to comment https://forums.phpfreaks.com/topic/90658-colour-ordered-text/#findComment-464784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.