You are here

public function FrxSyntaxEngine::replaceNested in Forena Reports 7.4

Replaces nested array data.

Parameters

$data: The array containing values to replace.

$raw: TRUE implies no formatting of data.

File

./FrxSyntaxEngine.inc, line 206
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 replaceNested(&$data, $raw = TRUE) {
  if (is_array($data)) {
    $values = $data;
    foreach ($values as $k => $value) {

      // Replace key data
      $key = $k;
      if (strpos($k, '{') !== FALSE) {
        $key = $this
          ->replace($key);
        unset($data[$k]);
        $data[$key] = $value;
      }

      // Replace value data.
      if (is_array($value)) {
        $this
          ->replaceNested($data[$key], $raw);
      }
      else {
        $data[$key] = $this
          ->replace($value, $raw);
      }
    }
  }
  else {
    $data = $this
      ->replace($data, $raw);
  }
}