function bestColor($bg, $lt = '#ffffff', $dk = '#000000') { if (empty($bg)) { $bg = $lt; } $bg = str_replace('#', '', $bg); $dk = str_replace('#', '', $dk); $base = new CSS_Color($bg); return '#' . $base->calcFG($bg, $dk); }