function inverseHex($color) { $color = TRIM($color); $prependHash = FALSE; if (STRPOS($color, '#') !== FALSE) { $prependHash = TRUE; $color = STR_REPLACE('#', NULL, $color); } switch ($len = STRLEN($color)) { case 3: $color = PREG_REPLACE("/(.)(.)(.)/", "\\1\\1\\2\\2\\3\\3", $color); case 6: break; default: TRIGGER_ERROR("Invalid hex length ({$len}). Must be (3) or (6)", E_USER_ERROR); } if (!PREG_MATCH('/[a-f0-9]{6}/i', $color)) { $color = HTMLENTITIES($color); TRIGGER_ERROR("Invalid hex string #{$color}", E_USER_ERROR); } $r = DECHEX(255 - HEXDEC(SUBSTR($color, 0, 2))); $r = STRLEN($r) > 1 ? $r : '0' . $r; $g = DECHEX(255 - HEXDEC(SUBSTR($color, 2, 2))); $g = STRLEN($g) > 1 ? $g : '0' . $g; $b = DECHEX(255 - HEXDEC(SUBSTR($color, 4, 2))); $b = STRLEN($b) > 1 ? $b : '0' . $b; return ($prependHash ? '#' : NULL) . $r . $g . $b; }
public function clear_td_tags(&$cells, $extag) { $exre = "/<" . $extag . ".[^>]+>/i"; $matches = array(); //print_R($cells); for ($i = 0, $n = COUNT($cells); $i < $n; $i++) { for ($j = 0, $nj = COUNT($cells[$i]); $j < $nj; $j++) { $cell = $cells[$i][$j]; if (PREG_MATCH($exre, $cell, $matches)) { //echo "$extag:this tag find $matches[0] n "; } else { $cells[$i][$j] = $this->clearTag($cell); //echo "not find:".$cells[$i][$j][$k] ."n"; } } //for 2 } //for 1 return $cells; }