You are here

public function FrxSyntaxEngine::object_to_array in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
  2. 6 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
  3. 7.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
  4. 7.4 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()

Convert an object into an array

Parameters

mixed $data: Iterates the object and builds an array of strings from it. If the object appears to be an xml object and has an attributes method, do the same for it.

File

./FrxSyntaxEngine.inc, line 137
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 object_to_array($data) {
  if (is_object($data)) {
    $ar = array();
    foreach ($data as $key => $value) {
      $ar[$key] = (string) $value;
    }
    if (method_exists($data, 'attributes')) {
      foreach ($data
        ->attributes() as $key => $value) {
        $ar[$key] = (string) $value;
      }
    }
    return $ar;
  }
  else {
    return $data;
  }
}