How to detect "light" colors with PHP
<p>I am working on a dynamic store project and I use a loop to print all color options for a product as color boxes, however I really need to add a "border" to these colors which are light. I tried something like the following but It is very limited, it is actually limited to white color only, it won't catch something like #ddd, #eea... etc</p>

<p>Here is my loop:</p>

<pre><code>   foreach($colors as $color) {
                $color = trim($color);
                if (!empty($color)) {
                    if (in_array($color, array('white','White','#fff','#FFF','#FFFFFF','#ffffff'))) {
                        $bordercolor = '#bbb';
                    } else {
                        $bordercolor = $color;
                    }
                }
    }
</code></pre>

<p>Colors is an array from backend like: White, #000, #cc0000, etc. It is not practical to add all exceptions in the if/else condition too, any quick idea?</p>
