static function compile_rules($rules) { $compiled_rules = []; if (is_string($rules)) { $rules = preg_split('/[\\s,]+/', $rules); $rules = Arrays::remove($rules); # remove empty rules, probably unintended by spacing after or before } foreach ($rules as $rule) { $compiled_rules[] = self::compile_rule($rule); } return $compiled_rules; }
static function specialSyntaxKeys($string) { if (preg_match('@^([^\\[]+)((\\[[^\\]]*\\])+)$@', $string, $match)) { //match[1] = array name, match[2] = all keys //get names of all keys preg_match_all('@\\[([^\\]]*)\\]@', $match[2], $matches); //add array name to beginning of keys list array_unshift($matches[1], $match[1]); //clear out empty key items Arrays::remove($matches[1], '', true); return $matches[1]; } }
static function explode($separator, $string) { $array = explode($separator, $string); Arrays::remove($array); return array_values($array); }