What alternative approaches can be used to assign colors based on array values in PHP, without using <font> tags?

When assigning colors based on array values in PHP without using <font> tags, one alternative approach is to use inline CSS styles. This can be achieved by dynamically generating CSS classes based on the array values and applying them to the HTML elements. Another approach is to use the style attribute directly on the HTML elements to set the color based on the array values.

&lt;?php
$array = [1, 2, 3, 4, 5];

foreach ($array as $value) {
    $color = ($value % 2 == 0) ? &#039;blue&#039; : &#039;red&#039;; // Example logic to determine color based on array value

    echo &quot;&lt;div style=&#039;color: $color;&#039;&gt;$value&lt;/div&gt;&quot;;
}
?&gt;