public function discard_invalid_selectors(&$array) {
		$invalid = array('+' => true, '~' => true, ',' => true, '>' => true);
		foreach ($array as $selector => $decls) {
			$ok = true;
			$selectors = array_map('trim', explode(',', $selector));
			foreach ($selectors as $s) {
				$simple_selectors = preg_split('/\s*[+>~\s]\s*/', $s);
				foreach ($simple_selectors as $ss) {
					if ($ss === '')
						$ok = false;
					// could also check $ss for internal structure,
					// but that probably would be too slow
				}
			}
			if (!$ok)
				unset($array[$selector]);
		}
	}
public function discard_invalid_selectors(&$array) {
		$invalid = array('+' => true, '~' => true, ',' => true, '>' => true);
		foreach ($array as $selector => $decls) {
			$ok = true;
			$selectors = array_map('trim', explode(',', $selector));
			foreach ($selectors as $s) {
				$simple_selectors = preg_split('/\s*[+>~\s]\s*/', $s);
				foreach ($simple_selectors as $ss) {
					if ($ss === '')
						$ok = false;
					// could also check $ss for internal structure,
					// but that probably would be too slow
				}
			}
			if (!$ok)
				unset($array[$selector]);
		}
	}
public function discard_invalid_selectors ( & $ array ) { $ invalid = array ( '+' => true , '~' => true , ',' => true , '>' => true ) ; foreach ( $ array as $ selector => $ decls ) { $ ok = true ; $ selectors = array_map ( 'trim' , explode ( ',' , $ selector ) ) ; foreach ( $ selectors as $ s ) { $ simple_selectors = preg_split ( '/\s*[+>~\s]\s*/' , $ s ) ; foreach ( $ simple_selectors as $ ss ) { if ( $ ss === '' ) $ ok = false ; // could also check $ss for internal structure, // but that probably would be too slow } } if ( ! $ ok ) unset ( $ array [ $ selector ] ) ; } }
Removes invalid selectors and their corresponding rule-sets as
defined by 4.1.7 in REC-CSS2. This is a very rudimentary check
and should be replaced by a full-blown parsing algorithm or
regular expression
@version 1.4
Removes invalid selectors and their corresponding rule - sets as defined by 4 . 1 . 7 in REC - CSS2 . This is a very rudimentary check and should be replaced by a full - blown parsing algorithm or regular expression