1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Development Discussions' started by Marcus, Oct 13, 2015.

  1. Marcus

    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] => [_count:protected] => [_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] => [*_count] => [*_data] => Array ( [value1] => one [value2] => two ) [*_skipNextIteration] => [*_loadedSection] => [*_extends] => Array ( ) [*_loadFileErrorStr] => ) \n
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The Zend_Config object has a toArray() function.

    That will return the data as an associative array.
     
    Marcus likes this.
  3. Marcus

    Marcus Well-Known Member

    Awesome, thanks.
     

Share This Page