pxxb Posted September 26, 2013 Share Posted September 26, 2013 I am trying to display all the contents of the array but I want to make "Chicken" in red font. How can I do this? I am new to Php. TY $animals = array("goat", "pig", "chicken","lion); //arrayforeach ($animals as $word){ //print all of arrayecho $word; Link to comment https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/ Share on other sites More sharing options...
mac_gyver Posted September 26, 2013 Share Posted September 26, 2013 you would declare a css class to use the color red. then when you are outputting the values form the array, for the value you want, you would surround it with a <span></span> tag with the css class you have declared. Link to comment https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/#findComment-1451236 Share on other sites More sharing options...
pxxb Posted September 26, 2013 Author Share Posted September 26, 2013 you would declare a css class to use the color red. then when you are outputting the values form the array, for the value you want, you would surround it with a <span></span> tag with the css class you have declared. So would I do something like: foreach ($animals as $word){ '<span class ="red" >' $animals[2] '</span>' echo $word; That would make only chicken red when printing entire array? Link to comment https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/#findComment-1451237 Share on other sites More sharing options...
Zane Posted September 26, 2013 Share Posted September 26, 2013 foreach ($animals as $word){ if($word == "chicken") echo '' $animals[2] ''; else echo $word; } Link to comment https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/#findComment-1451240 Share on other sites More sharing options...
pxxb Posted September 26, 2013 Author Share Posted September 26, 2013 foreach ($animals as $word){ if($word == "chicken") echo '<span class ="red" >' $animals[2] '</span>'; else echo $word; } thank you. Link to comment https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/#findComment-1451241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.