You need to separately set the style for the first element from the array, the array is set by divs and the elements are identical to each other. Can you tell me how to do this?

2 answers 2

For example:

div:first-child { color: red; } 

Here is an example .

     $first = 1; foreach ($array as $text) { echo '<div' if ($first) { echo ' style="color:red"'} else $first--; echo '>'.$text.'</div>'; } 

    Or:

     echo '<div style="color:red">'.$array[0].'</div>'; for ($i = 1, $c = count($array); $i < $c; $i++) echo '<div>'.$array[$i].'</div>'; 

    This is what is clear from the question.