Jump to content

Help changing array to different color?


pxxb

Recommended Posts

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);    //array

foreach ($animals as $word){                              //print all of array
echo $word;

Link to comment
https://forums.phpfreaks.com/topic/282447-help-changing-array-to-different-color/
Share on other sites

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.