XenForo_Application::get('config') returns Zend Object instead of Array

Marcus

Well-known member
I would like to return the exact array or value from /library/config.php

in config.php
PHP:
$config['test'] = [
  'value1' => 'one',
  'value2'  => 'two',
];

PHP:
$configphp = XenForo_Application::get('config')->test;
print_r($configphp);
returns
PHP:
Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 2 [_data:protected] => Array ( [value1] => one [value2] => two ) [_skipNextIteration:protected] => [_loadedSection:protected] => [_extends:protected] => Array ( ) [_loadFileErrorStr:protected] => ) \n

When I try to convert it to (array) ...
PHP:
$configphp = (array)XenForo_Application::get('config')->test;
print_r($configphp);
returns
PHP:
Array ( [*_allowModifications] => [*_index] => 0 [*_count] => 3 [*_data] => Array ( [value1] => one [value2] => two ) [*_skipNextIteration] => [*_loadedSection] => [*_extends] => Array ( ) [*_loadFileErrorStr] => ) \n
 
The Zend_Config object has a toArray() function.

That will return the data as an associative array.
 
Back
Top Bottom