You are here

public function FrxSyntaxEngine::tokens in Forena Reports 7.4

Same name and namespace in other branches
  1. 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::tokens()
  2. 6 FrxSyntaxEngine.inc \FrxSyntaxEngine::tokens()
  3. 7 FrxSyntaxEngine.inc \FrxSyntaxEngine::tokens()
  4. 7.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::tokens()
  5. 7.3 FrxSyntaxEngine.inc \FrxSyntaxEngine::tokens()

List all of the tokens used in a piece of text, ignoring duplicates.

Parameters

string $text:

Return value

array tokens contained in the text according to the regular expression.

File

./FrxSyntaxEngine.inc, line 127
FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.

Class

FrxSyntaxEngine
@file FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.

Code

public function tokens($text) {
  $match = array();
  $tokens = array();
  if (preg_match_all($this->tpattern, $text, $match)) {
    foreach ($match[0] as $match_num => $token) {
      $path = trim($token, $this->trim_chars);
      if (array_search($path, $tokens) === FALSE) {
        $tokens[] = $path;
      }
    }
  }
  return $tokens;
}