/ Published in: PHP
Returns the color (red to green) when you give a percentage amount, or reversible.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//color temperatures (for funsies) //straight = red to green, reverse = green to red function getTemperatureColor($percentage, $type="straight") { $colors = array("#ff0200", "#ff270a", "#ff5306" ,"#ffa801", "#ffd301", "#eef302", "#c0ff02", "#73ff01", "#27ff01", "#00ff00"); $colors = array("#c43c35", "#d65227", "#f27312" ,"#f57711", "#f8840a", "#e89b0a", "#bda119", "#9fa225", "#7ba332", "#47a546"); if ($type == "reverse") { } if ($percentage >= 100) { return $colors[9]; } else if ($percentage <= 9) { return $colors[0]; } //for the double digits return $colors[$number]; }