public function FrxSyntaxEngine::object_to_array in Forena Reports 6.2
Same name and namespace in other branches
- 6 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
- 7.2 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
- 7.3 FrxSyntaxEngine.inc \FrxSyntaxEngine::object_to_array()
- 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 186 - 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
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;
}
}