matchers[$matcher->order] = $matcher; $types[$matcher->section] = $matcher->type; if ($matcher->type == 'default') $default = $matcher; } } $default->types = $types; ksort($this->matchers); } function match($text) { $matches = array(); $matched = false; foreach ($this->matchers as $matcher) { if ($matcher->match($text) === true) { $matches = array_merge($matches, $matcher->items); $matched = true; } } $this->all= $matches; $this->first = $matches[0]; return $matched; } function getIterator() { return new ArrayIterator($this->matchers); } } /** * Base class for all Matchers */ class SI_Entry { public $order = 0; // order in which to use this matcher public $items = array(); // the different elements of the match: section, display, entry, type public $type = 'default'; // type of entry matched public $section = 0; // section this entry will be added to public $regex = ''; function match() { } }